// SPDX-License-Identifier: GPL-2.0/* * Networking over Thunderbolt/USB4 cables using USB4NET protocol * (formerly Apple ThunderboltIP). * * Copyright (C) 2017, Intel Corporation * Authors: Amir Levy <amir.jer.levy@intel.com> * Michael Jamet <michael.jamet@intel.com> * Mika Westerberg <mika.westerberg@linux.intel.com> */#include<linux/atomic.h>#include<linux/highmem.h>#include<linux/if_vlan.h>#include<linux/jhash.h>#include<linux/module.h>#include<linux/etherdevice.h>#include<linux/rtnetlink.h>#include<linux/sizes.h>#include<linux/thunderbolt.h>#include<linux/uuid.h>#include<linux/workqueue.h>#include<net/ip6_checksum.h>#include"trace.h"/* Protocol timeouts in ms */#define TBNET_LOGIN_DELAY 4500#define TBNET_LOGIN_TIMEOUT 500#define TBNET_LOGOUT_TIMEOUT 1000#define TBNET_RING_SIZE 256#define TBNET_LOGIN_RETRIES 60#define TBNET_LOGOUT_RETRIES 10#define TBNET_E2E BIT(0)#define TBNET_MATCH_FRAGS_ID BIT(1)#define TBNET_64K_FRAMES BIT(2)#define TBNET_MAX_MTU SZ_64K#define TBNET_FRAME_SIZE SZ_4K#define TBNET_MAX_PAYLOAD_SIZE \ (TBNET_FRAME_SIZE - sizeof(struct thunderbolt_ip_frame_header))/* Rx packets need to hold space for skb_shared_info */#define TBNET_RX_MAX_SIZE \ (TBNET_FRAME_SIZE + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))#define TBNET_RX_PAGE_ORDER get_order(TBNET_RX_MAX_SIZE)#define TBNET_RX_PAGE_SIZE (PAGE_SIZE << TBNET_RX_PAGE_ORDER)#define TBNET_L0_PORT_NUM(route) ((route) & GENMASK(5, 0))/** * struct thunderbolt_ip_frame_header - Header for each Thunderbolt frame * @frame_size: size of the data with the frame * @frame_index: running index on the frames * @frame_id: ID of the frame to match frames to specific packet * @frame_count: how many frames assembles a full packet * * Each data frame passed to the high-speed DMA ring has this header. If * the XDomain network directory announces that %TBNET_MATCH_FRAGS_ID is * supported then @frame_id is filled, otherwise it stays %0. */structthunderbolt_ip_frame_header{__le32frame_size;__le16frame_index;__le16frame_id;__le32frame_count;};enumthunderbolt_ip_frame_pdf{