Commit ce1b75d0 authored by Pavan Kumar Linga's avatar Pavan Kumar Linga Committed by Tony Nguyen

idpf: add ptypes and MAC filter support

Add the virtchnl support to request the packet types. Parse the responses
received from CP and based on the protocol headers, populate the packet
type structure with necessary information. Initialize the MAC address
and add the virtchnl support to add and del MAC address.
Co-developed-by: default avatarAlan Brady <alan.brady@intel.com>
Signed-off-by: default avatarAlan Brady <alan.brady@intel.com>
Co-developed-by: default avatarJoshua Hay <joshua.a.hay@intel.com>
Signed-off-by: default avatarJoshua Hay <joshua.a.hay@intel.com>
Co-developed-by: default avatarMadhu Chittim <madhu.chittim@intel.com>
Signed-off-by: default avatarMadhu Chittim <madhu.chittim@intel.com>
Co-developed-by: default avatarPhani Burra <phani.r.burra@intel.com>
Signed-off-by: default avatarPhani Burra <phani.r.burra@intel.com>
Co-developed-by: default avatarShailendra Bhatnagar <shailendra.bhatnagar@intel.com>
Signed-off-by: default avatarShailendra Bhatnagar <shailendra.bhatnagar@intel.com>
Reviewed-by: default avatarSridhar Samudrala <sridhar.samudrala@intel.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarPavan Kumar Linga <pavan.kumar.linga@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 0fe45467
...@@ -21,6 +21,7 @@ struct idpf_vport_max_q; ...@@ -21,6 +21,7 @@ struct idpf_vport_max_q;
#define IDPF_NO_FREE_SLOT 0xffff #define IDPF_NO_FREE_SLOT 0xffff
/* Default Mailbox settings */ /* Default Mailbox settings */
#define IDPF_NUM_FILTERS_PER_MSG 20
#define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */ #define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */
#define IDPF_DFLT_MBX_Q_LEN 64 #define IDPF_DFLT_MBX_Q_LEN 64
#define IDPF_DFLT_MBX_ID -1 #define IDPF_DFLT_MBX_ID -1
...@@ -37,6 +38,20 @@ struct idpf_vport_max_q; ...@@ -37,6 +38,20 @@ struct idpf_vport_max_q;
#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2 #define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2
#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0 #define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0
/**
* struct idpf_mac_filter
* @list: list member field
* @macaddr: MAC address
* @remove: filter should be removed (virtchnl)
* @add: filter should be added (virtchnl)
*/
struct idpf_mac_filter {
struct list_head list;
u8 macaddr[ETH_ALEN];
bool remove;
bool add;
};
/** /**
* enum idpf_state - State machine to handle bring up * enum idpf_state - State machine to handle bring up
* @__IDPF_STARTUP: Start the state machine * @__IDPF_STARTUP: Start the state machine
...@@ -115,11 +130,17 @@ enum idpf_vport_state { ...@@ -115,11 +130,17 @@ enum idpf_vport_state {
/** /**
* struct idpf_netdev_priv - Struct to store vport back pointer * struct idpf_netdev_priv - Struct to store vport back pointer
* @adapter: Adapter back pointer
* @vport: Vport back pointer * @vport: Vport back pointer
* @vport_id: Vport identifier
* @vport_idx: Relative vport index
* @state: See enum idpf_vport_state * @state: See enum idpf_vport_state
*/ */
struct idpf_netdev_priv { struct idpf_netdev_priv {
struct idpf_adapter *adapter;
struct idpf_vport *vport; struct idpf_vport *vport;
u32 vport_id;
u16 vport_idx;
enum idpf_vport_state state; enum idpf_vport_state state;
}; };
...@@ -184,6 +205,12 @@ struct idpf_dev_ops { ...@@ -184,6 +205,12 @@ struct idpf_dev_ops {
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
STATE(IDPF_VC_DEALLOC_VECTORS) \ STATE(IDPF_VC_DEALLOC_VECTORS) \
STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \
STATE(IDPF_VC_ADD_MAC_ADDR) \
STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \
STATE(IDPF_VC_DEL_MAC_ADDR) \
STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \
STATE(IDPF_VC_GET_PTYPE_INFO) \
STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \
STATE(IDPF_VC_NBITS) STATE(IDPF_VC_NBITS)
#define IDPF_GEN_ENUM(ENUM) ENUM, #define IDPF_GEN_ENUM(ENUM) ENUM,
...@@ -213,6 +240,7 @@ extern const char * const idpf_vport_vc_state_str[]; ...@@ -213,6 +240,7 @@ extern const char * const idpf_vport_vc_state_str[];
* @bufq_size: Size of buffers in ring (e.g. 2K, 4K, etc) * @bufq_size: Size of buffers in ring (e.g. 2K, 4K, etc)
* @num_rxq_grp: Number of RX queues in a group * @num_rxq_grp: Number of RX queues in a group
* @rxq_model: Splitq queue or single queue queuing model * @rxq_model: Splitq queue or single queue queuing model
* @rx_ptype_lkup: Lookup table for ptypes on RX
* @adapter: back pointer to associated adapter * @adapter: back pointer to associated adapter
* @netdev: Associated net_device. Each vport should have one and only one * @netdev: Associated net_device. Each vport should have one and only one
* associated netdev. * associated netdev.
...@@ -220,6 +248,7 @@ extern const char * const idpf_vport_vc_state_str[]; ...@@ -220,6 +248,7 @@ extern const char * const idpf_vport_vc_state_str[];
* @vport_id: Device given vport identifier * @vport_id: Device given vport identifier
* @idx: Software index in adapter vports struct * @idx: Software index in adapter vports struct
* @default_vport: Use this vport if one isn't specified * @default_vport: Use this vport if one isn't specified
* @base_rxd: True if the driver should use base descriptors instead of flex
* @max_mtu: device given max possible MTU * @max_mtu: device given max possible MTU
* @default_mac_addr: device will give a default MAC to use * @default_mac_addr: device will give a default MAC to use
* @vc_msg: Virtchnl message buffer * @vc_msg: Virtchnl message buffer
...@@ -242,6 +271,7 @@ struct idpf_vport { ...@@ -242,6 +271,7 @@ struct idpf_vport {
u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP]; u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP];
u16 num_rxq_grp; u16 num_rxq_grp;
u32 rxq_model; u32 rxq_model;
struct idpf_rx_ptype_decoded rx_ptype_lkup[IDPF_RX_MAX_PTYPE];
struct idpf_adapter *adapter; struct idpf_adapter *adapter;
struct net_device *netdev; struct net_device *netdev;
...@@ -249,6 +279,7 @@ struct idpf_vport { ...@@ -249,6 +279,7 @@ struct idpf_vport {
u32 vport_id; u32 vport_id;
u16 idx; u16 idx;
bool default_vport; bool default_vport;
bool base_rxd;
u16 max_mtu; u16 max_mtu;
u8 default_mac_addr[ETH_ALEN]; u8 default_mac_addr[ETH_ALEN];
...@@ -269,6 +300,7 @@ struct idpf_vport { ...@@ -269,6 +300,7 @@ struct idpf_vport {
* ethtool * ethtool
* @num_req_rxq_desc: Number of user requested RX queue descriptors through * @num_req_rxq_desc: Number of user requested RX queue descriptors through
* ethtool * ethtool
* @mac_filter_list: List of MAC filters
* *
* Used to restore configuration after a reset as the vport will get wiped. * Used to restore configuration after a reset as the vport will get wiped.
*/ */
...@@ -277,17 +309,22 @@ struct idpf_vport_user_config_data { ...@@ -277,17 +309,22 @@ struct idpf_vport_user_config_data {
u16 num_req_rx_qs; u16 num_req_rx_qs;
u32 num_req_txq_desc; u32 num_req_txq_desc;
u32 num_req_rxq_desc; u32 num_req_rxq_desc;
struct list_head mac_filter_list;
}; };
/** /**
* enum idpf_vport_config_flags - Vport config flags * enum idpf_vport_config_flags - Vport config flags
* @IDPF_VPORT_REG_NETDEV: Register netdev * @IDPF_VPORT_REG_NETDEV: Register netdev
* @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset * @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset
* @IDPF_VPORT_ADD_MAC_REQ: Asynchronous add ether address in flight
* @IDPF_VPORT_DEL_MAC_REQ: Asynchronous delete ether address in flight
* @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last * @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last
*/ */
enum idpf_vport_config_flags { enum idpf_vport_config_flags {
IDPF_VPORT_REG_NETDEV, IDPF_VPORT_REG_NETDEV,
IDPF_VPORT_UP_REQUESTED, IDPF_VPORT_UP_REQUESTED,
IDPF_VPORT_ADD_MAC_REQ,
IDPF_VPORT_DEL_MAC_REQ,
IDPF_VPORT_CONFIG_FLAGS_NBITS, IDPF_VPORT_CONFIG_FLAGS_NBITS,
}; };
...@@ -335,11 +372,13 @@ struct idpf_vector_lifo { ...@@ -335,11 +372,13 @@ struct idpf_vector_lifo {
* struct idpf_vport_config - Vport configuration data * struct idpf_vport_config - Vport configuration data
* @user_config: see struct idpf_vport_user_config_data * @user_config: see struct idpf_vport_user_config_data
* @max_q: Maximum possible queues * @max_q: Maximum possible queues
* @mac_filter_list_lock: Lock to protect mac filters
* @flags: See enum idpf_vport_config_flags * @flags: See enum idpf_vport_config_flags
*/ */
struct idpf_vport_config { struct idpf_vport_config {
struct idpf_vport_user_config_data user_config; struct idpf_vport_user_config_data user_config;
struct idpf_vport_max_q max_q; struct idpf_vport_max_q max_q;
spinlock_t mac_filter_list_lock;
DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS); DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
}; };
...@@ -592,6 +631,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter); ...@@ -592,6 +631,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter);
int idpf_intr_req(struct idpf_adapter *adapter); int idpf_intr_req(struct idpf_adapter *adapter);
void idpf_intr_rel(struct idpf_adapter *adapter); void idpf_intr_rel(struct idpf_adapter *adapter);
int idpf_send_destroy_vport_msg(struct idpf_vport *vport); int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter); int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors); int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
void idpf_deinit_task(struct idpf_adapter *adapter); void idpf_deinit_task(struct idpf_adapter *adapter);
...@@ -606,9 +646,13 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter, ...@@ -606,9 +646,13 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,
struct idpf_vport_max_q *max_q); struct idpf_vport_max_q *max_q);
void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter, void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
struct idpf_vport_max_q *max_q); struct idpf_vport_max_q *max_q);
int idpf_add_del_mac_filters(struct idpf_vport *vport,
struct idpf_netdev_priv *np,
bool add, bool async);
void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q); void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
u32 idpf_get_vport_id(struct idpf_vport *vport); u32 idpf_get_vport_id(struct idpf_vport *vport);
int idpf_send_create_vport_msg(struct idpf_adapter *adapter, int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
struct idpf_vport_max_q *max_q); struct idpf_vport_max_q *max_q);
int idpf_check_supported_desc_ids(struct idpf_vport *vport);
#endif /* !_IDPF_H_ */ #endif /* !_IDPF_H_ */
...@@ -293,6 +293,158 @@ int idpf_intr_req(struct idpf_adapter *adapter) ...@@ -293,6 +293,158 @@ int idpf_intr_req(struct idpf_adapter *adapter)
return err; return err;
} }
/**
* idpf_find_mac_filter - Search filter list for specific mac filter
* @vconfig: Vport config structure
* @macaddr: The MAC address
*
* Returns ptr to the filter object or NULL. Must be called while holding the
* mac_filter_list_lock.
**/
static struct idpf_mac_filter *idpf_find_mac_filter(struct idpf_vport_config *vconfig,
const u8 *macaddr)
{
struct idpf_mac_filter *f;
if (!macaddr)
return NULL;
list_for_each_entry(f, &vconfig->user_config.mac_filter_list, list) {
if (ether_addr_equal(macaddr, f->macaddr))
return f;
}
return NULL;
}
/**
* __idpf_add_mac_filter - Add mac filter helper function
* @vport_config: Vport config structure
* @macaddr: Address to add
*
* Takes mac_filter_list_lock spinlock to add new filter to list.
*/
static int __idpf_add_mac_filter(struct idpf_vport_config *vport_config,
const u8 *macaddr)
{
struct idpf_mac_filter *f;
spin_lock_bh(&vport_config->mac_filter_list_lock);
f = idpf_find_mac_filter(vport_config, macaddr);
if (f) {
f->remove = false;
spin_unlock_bh(&vport_config->mac_filter_list_lock);
return 0;
}
f = kzalloc(sizeof(*f), GFP_ATOMIC);
if (!f) {
spin_unlock_bh(&vport_config->mac_filter_list_lock);
return -ENOMEM;
}
ether_addr_copy(f->macaddr, macaddr);
list_add_tail(&f->list, &vport_config->user_config.mac_filter_list);
f->add = true;
spin_unlock_bh(&vport_config->mac_filter_list_lock);
return 0;
}
/**
* idpf_add_mac_filter - Add a mac filter to the filter list
* @vport: Main vport structure
* @np: Netdev private structure
* @macaddr: The MAC address
* @async: Don't wait for return message
*
* Returns 0 on success or error on failure. If interface is up, we'll also
* send the virtchnl message to tell hardware about the filter.
**/
static int idpf_add_mac_filter(struct idpf_vport *vport,
struct idpf_netdev_priv *np,
const u8 *macaddr, bool async)
{
struct idpf_vport_config *vport_config;
int err;
vport_config = np->adapter->vport_config[np->vport_idx];
err = __idpf_add_mac_filter(vport_config, macaddr);
if (err)
return err;
if (np->state == __IDPF_VPORT_UP)
err = idpf_add_del_mac_filters(vport, np, true, async);
return err;
}
/**
* idpf_deinit_mac_addr - deinitialize mac address for vport
* @vport: main vport structure
*/
static void idpf_deinit_mac_addr(struct idpf_vport *vport)
{
struct idpf_vport_config *vport_config;
struct idpf_mac_filter *f;
vport_config = vport->adapter->vport_config[vport->idx];
spin_lock_bh(&vport_config->mac_filter_list_lock);
f = idpf_find_mac_filter(vport_config, vport->default_mac_addr);
if (f) {
list_del(&f->list);
kfree(f);
}
spin_unlock_bh(&vport_config->mac_filter_list_lock);
}
/**
* idpf_init_mac_addr - initialize mac address for vport
* @vport: main vport structure
* @netdev: pointer to netdev struct associated with this vport
*/
static int idpf_init_mac_addr(struct idpf_vport *vport,
struct net_device *netdev)
{
struct idpf_netdev_priv *np = netdev_priv(netdev);
struct idpf_adapter *adapter = vport->adapter;
int err;
if (is_valid_ether_addr(vport->default_mac_addr)) {
eth_hw_addr_set(netdev, vport->default_mac_addr);
ether_addr_copy(netdev->perm_addr, vport->default_mac_addr);
return idpf_add_mac_filter(vport, np, vport->default_mac_addr,
false);
}
if (!idpf_is_cap_ena(adapter, IDPF_OTHER_CAPS,
VIRTCHNL2_CAP_MACFILTER)) {
dev_err(&adapter->pdev->dev,
"MAC address is not provided and capability is not set\n");
return -EINVAL;
}
eth_hw_addr_random(netdev);
err = idpf_add_mac_filter(vport, np, netdev->dev_addr, false);
if (err)
return err;
dev_info(&adapter->pdev->dev, "Invalid MAC address %pM, using random %pM\n",
vport->default_mac_addr, netdev->dev_addr);
ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
return 0;
}
/** /**
* idpf_cfg_netdev - Allocate, configure and register a netdev * idpf_cfg_netdev - Allocate, configure and register a netdev
* @vport: main vport structure * @vport: main vport structure
...@@ -308,6 +460,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) ...@@ -308,6 +460,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
struct idpf_netdev_priv *np; struct idpf_netdev_priv *np;
struct net_device *netdev; struct net_device *netdev;
u16 idx = vport->idx; u16 idx = vport->idx;
int err;
vport_config = adapter->vport_config[idx]; vport_config = adapter->vport_config[idx];
...@@ -318,9 +471,11 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) ...@@ -318,9 +471,11 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
netdev = adapter->netdevs[idx]; netdev = adapter->netdevs[idx];
np = netdev_priv(netdev); np = netdev_priv(netdev);
np->vport = vport; np->vport = vport;
np->vport_idx = vport->idx;
np->vport_id = vport->vport_id;
vport->netdev = netdev; vport->netdev = netdev;
return 0; return idpf_init_mac_addr(vport, netdev);
} }
netdev = alloc_etherdev_mqs(sizeof(struct idpf_netdev_priv), netdev = alloc_etherdev_mqs(sizeof(struct idpf_netdev_priv),
...@@ -332,6 +487,17 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) ...@@ -332,6 +487,17 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
vport->netdev = netdev; vport->netdev = netdev;
np = netdev_priv(netdev); np = netdev_priv(netdev);
np->vport = vport; np->vport = vport;
np->adapter = adapter;
np->vport_idx = vport->idx;
np->vport_id = vport->vport_id;
err = idpf_init_mac_addr(vport, netdev);
if (err) {
free_netdev(vport->netdev);
vport->netdev = NULL;
return err;
}
/* setup watchdog timeout value to be 5 second */ /* setup watchdog timeout value to be 5 second */
netdev->watchdog_timeo = 5 * HZ; netdev->watchdog_timeo = 5 * HZ;
...@@ -495,6 +661,8 @@ static void idpf_vport_dealloc(struct idpf_vport *vport) ...@@ -495,6 +661,8 @@ static void idpf_vport_dealloc(struct idpf_vport *vport)
struct idpf_adapter *adapter = vport->adapter; struct idpf_adapter *adapter = vport->adapter;
unsigned int i = vport->idx; unsigned int i = vport->idx;
idpf_deinit_mac_addr(vport);
if (!test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags)) if (!test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags))
idpf_decfg_netdev(vport); idpf_decfg_netdev(vport);
...@@ -617,6 +785,7 @@ void idpf_service_task(struct work_struct *work) ...@@ -617,6 +785,7 @@ void idpf_service_task(struct work_struct *work)
*/ */
void idpf_init_task(struct work_struct *work) void idpf_init_task(struct work_struct *work)
{ {
struct idpf_vport_config *vport_config;
struct idpf_vport_max_q max_q; struct idpf_vport_max_q max_q;
struct idpf_adapter *adapter; struct idpf_adapter *adapter;
struct idpf_vport *vport; struct idpf_vport *vport;
...@@ -654,14 +823,28 @@ void idpf_init_task(struct work_struct *work) ...@@ -654,14 +823,28 @@ void idpf_init_task(struct work_struct *work)
} }
index = vport->idx; index = vport->idx;
vport_config = adapter->vport_config[index];
init_waitqueue_head(&vport->vchnl_wq); init_waitqueue_head(&vport->vchnl_wq);
mutex_init(&vport->vc_buf_lock); mutex_init(&vport->vc_buf_lock);
spin_lock_init(&vport_config->mac_filter_list_lock);
INIT_LIST_HEAD(&vport_config->user_config.mac_filter_list);
err = idpf_check_supported_desc_ids(vport);
if (err) {
dev_err(&pdev->dev, "failed to get required descriptor ids\n");
goto cfg_netdev_err;
}
if (idpf_cfg_netdev(vport)) if (idpf_cfg_netdev(vport))
goto cfg_netdev_err; goto cfg_netdev_err;
err = idpf_send_get_rx_ptype_msg(vport);
if (err)
goto handle_err;
/* Spawn and return 'idpf_init_task' work queue until all the /* Spawn and return 'idpf_init_task' work queue until all the
* default vports are created * default vports are created
*/ */
...@@ -689,6 +872,8 @@ void idpf_init_task(struct work_struct *work) ...@@ -689,6 +872,8 @@ void idpf_init_task(struct work_struct *work)
return; return;
handle_err:
idpf_decfg_netdev(vport);
cfg_netdev_err: cfg_netdev_err:
idpf_vport_rel(vport); idpf_vport_rel(vport);
adapter->vports[index] = NULL; adapter->vports[index] = NULL;
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#define IDPF_MIN_TXQ_COMPLQ_DESC 256 #define IDPF_MIN_TXQ_COMPLQ_DESC 256
#define MIN_SUPPORT_TXDID (\
VIRTCHNL2_TXDID_FLEX_FLOW_SCHED |\
VIRTCHNL2_TXDID_FLEX_TSO_CTX)
#define IDPF_DFLT_SINGLEQ_TX_Q_GROUPS 1 #define IDPF_DFLT_SINGLEQ_TX_Q_GROUPS 1
#define IDPF_DFLT_SINGLEQ_RX_Q_GROUPS 1 #define IDPF_DFLT_SINGLEQ_RX_Q_GROUPS 1
#define IDPF_DFLT_SINGLEQ_TXQ_PER_GROUP 4 #define IDPF_DFLT_SINGLEQ_TXQ_PER_GROUP 4
...@@ -51,6 +55,115 @@ ...@@ -51,6 +55,115 @@
#define IDPF_PACKET_HDR_PAD \ #define IDPF_PACKET_HDR_PAD \
(ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN * 2) (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN * 2)
#define IDPF_RX_MAX_PTYPE_PROTO_IDS 32
#define IDPF_RX_MAX_PTYPE_SZ (sizeof(struct virtchnl2_ptype) + \
(sizeof(u16) * IDPF_RX_MAX_PTYPE_PROTO_IDS))
#define IDPF_RX_PTYPE_HDR_SZ sizeof(struct virtchnl2_get_ptype_info)
#define IDPF_RX_MAX_PTYPES_PER_BUF \
DIV_ROUND_DOWN_ULL((IDPF_CTLQ_MAX_BUF_LEN - IDPF_RX_PTYPE_HDR_SZ), \
IDPF_RX_MAX_PTYPE_SZ)
#define IDPF_GET_PTYPE_SIZE(p) struct_size((p), proto_id, (p)->proto_id_count)
#define IDPF_TUN_IP_GRE (\
IDPF_PTYPE_TUNNEL_IP |\
IDPF_PTYPE_TUNNEL_IP_GRENAT)
#define IDPF_TUN_IP_GRE_MAC (\
IDPF_TUN_IP_GRE |\
IDPF_PTYPE_TUNNEL_IP_GRENAT_MAC)
#define IDPF_RX_MAX_PTYPE 1024
#define IDPF_RX_MAX_BASE_PTYPE 256
#define IDPF_INVALID_PTYPE_ID 0xFFFF
/* Packet type non-ip values */
enum idpf_rx_ptype_l2 {
IDPF_RX_PTYPE_L2_RESERVED = 0,
IDPF_RX_PTYPE_L2_MAC_PAY2 = 1,
IDPF_RX_PTYPE_L2_TIMESYNC_PAY2 = 2,
IDPF_RX_PTYPE_L2_FIP_PAY2 = 3,
IDPF_RX_PTYPE_L2_OUI_PAY2 = 4,
IDPF_RX_PTYPE_L2_MACCNTRL_PAY2 = 5,
IDPF_RX_PTYPE_L2_LLDP_PAY2 = 6,
IDPF_RX_PTYPE_L2_ECP_PAY2 = 7,
IDPF_RX_PTYPE_L2_EVB_PAY2 = 8,
IDPF_RX_PTYPE_L2_QCN_PAY2 = 9,
IDPF_RX_PTYPE_L2_EAPOL_PAY2 = 10,
IDPF_RX_PTYPE_L2_ARP = 11,
};
enum idpf_rx_ptype_outer_ip {
IDPF_RX_PTYPE_OUTER_L2 = 0,
IDPF_RX_PTYPE_OUTER_IP = 1,
};
enum idpf_rx_ptype_outer_ip_ver {
IDPF_RX_PTYPE_OUTER_NONE = 0,
IDPF_RX_PTYPE_OUTER_IPV4 = 1,
IDPF_RX_PTYPE_OUTER_IPV6 = 2,
};
enum idpf_rx_ptype_outer_fragmented {
IDPF_RX_PTYPE_NOT_FRAG = 0,
IDPF_RX_PTYPE_FRAG = 1,
};
enum idpf_rx_ptype_tunnel_type {
IDPF_RX_PTYPE_TUNNEL_NONE = 0,
IDPF_RX_PTYPE_TUNNEL_IP_IP = 1,
IDPF_RX_PTYPE_TUNNEL_IP_GRENAT = 2,
IDPF_RX_PTYPE_TUNNEL_IP_GRENAT_MAC = 3,
IDPF_RX_PTYPE_TUNNEL_IP_GRENAT_MAC_VLAN = 4,
};
enum idpf_rx_ptype_tunnel_end_prot {
IDPF_RX_PTYPE_TUNNEL_END_NONE = 0,
IDPF_RX_PTYPE_TUNNEL_END_IPV4 = 1,
IDPF_RX_PTYPE_TUNNEL_END_IPV6 = 2,
};
enum idpf_rx_ptype_inner_prot {
IDPF_RX_PTYPE_INNER_PROT_NONE = 0,
IDPF_RX_PTYPE_INNER_PROT_UDP = 1,
IDPF_RX_PTYPE_INNER_PROT_TCP = 2,
IDPF_RX_PTYPE_INNER_PROT_SCTP = 3,
IDPF_RX_PTYPE_INNER_PROT_ICMP = 4,
IDPF_RX_PTYPE_INNER_PROT_TIMESYNC = 5,
};
enum idpf_rx_ptype_payload_layer {
IDPF_RX_PTYPE_PAYLOAD_LAYER_NONE = 0,
IDPF_RX_PTYPE_PAYLOAD_LAYER_PAY2 = 1,
IDPF_RX_PTYPE_PAYLOAD_LAYER_PAY3 = 2,
IDPF_RX_PTYPE_PAYLOAD_LAYER_PAY4 = 3,
};
enum idpf_tunnel_state {
IDPF_PTYPE_TUNNEL_IP = BIT(0),
IDPF_PTYPE_TUNNEL_IP_GRENAT = BIT(1),
IDPF_PTYPE_TUNNEL_IP_GRENAT_MAC = BIT(2),
};
struct idpf_ptype_state {
bool outer_ip;
bool outer_frag;
u8 tunnel_state;
};
struct idpf_rx_ptype_decoded {
u32 ptype:10;
u32 known:1;
u32 outer_ip:1;
u32 outer_ip_ver:2;
u32 outer_frag:1;
u32 tunnel_type:3;
u32 tunnel_end_prot:2;
u32 tunnel_end_frag:1;
u32 inner_prot:4;
u32 payload_layer:3;
};
/** /**
* struct idpf_intr_reg * struct idpf_intr_reg
* @dyn_ctl: Dynamic control interrupt register * @dyn_ctl: Dynamic control interrupt register
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment