2018-09-19 17:42:55 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/* Copyright (c) 2018, Intel Corporation. */
|
|
|
|
|
|
|
|
#ifndef _ICE_VIRTCHNL_PF_H_
|
|
|
|
#define _ICE_VIRTCHNL_PF_H_
|
|
|
|
#include "ice.h"
|
ice: Enable FDIR Configure for AVF
The virtual channel is going to be extended to support FDIR and
RSS configure from AVF. New data structures and OP codes will be
added, the patch enable the FDIR part.
To support above advanced AVF feature, we need to figure out
what kind of data structure should be passed from VF to PF to describe
an FDIR rule or RSS config rule. The common part of the requirement is
we need a data structure to represent the input set selection of a rule's
hash key.
An input set selection is a group of fields be selected from one or more
network protocol layers that could be identified as a specific flow.
For example, select dst IP address from an IPv4 header combined with
dst port from the TCP header as the input set for an IPv4/TCP flow.
The patch adds a new data structure virtchnl_proto_hdrs to abstract
a network protocol headers group which is composed of layers of network
protocol header(virtchnl_proto_hdr).
A protocol header contains a 32 bits mask (field_selector) to describe
which fields are selected as input sets, as well as a header type
(enum virtchnl_proto_hdr_type). Each bit is mapped to a field in
enum virtchnl_proto_hdr_field guided by its header type.
+------------+-----------+------------------------------+
| | Proto Hdr | Header Type A |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
|Proto Hdrs | Proto Hdr | Header Type B |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | Proto Hdr | Header Type C |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | .... |
+-------------------------------------------------------+
All fields in enum virtchnl_proto_hdr_fields are grouped with header type
and the value of the first field of a header type is always 32 aligned.
enum proto_hdr_type {
header_type_A = 0;
header_type_B = 1;
....
}
enum proto_hdr_field {
/* header type A */
header_A_field_0 = 0,
header_A_field_1 = 1,
header_A_field_2 = 2,
header_A_field_3 = 3,
/* header type B */
header_B_field_0 = 32, // = header_type_B << 5
header_B_field_0 = 33,
header_B_field_0 = 34
header_B_field_0 = 35,
....
};
So we have:
proto_hdr_type = proto_hdr_field / 32
bit offset = proto_hdr_field % 32
To simply the protocol header's operations, couple help macros are added.
For example, to select src IP and dst port as input set for an IPv4/UDP
flow.
we have:
struct virtchnl_proto_hdr hdr[2];
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[0], IPV4)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[0], IPV4, SRC)
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[1], UDP)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[1], UDP, DST)
The byte array is used to store the protocol header of a training package.
The byte array must be network order.
The patch added virtual channel support for iAVF FDIR add/validate/delete
filter. iAVF FDIR is Flow Director for Intel Adaptive Virtual Function
which can direct Ethernet packets to the queues of the Network Interface
Card. Add/delete command is adding or deleting one rule for each virtual
channel message, while validate command is just verifying if this rule
is valid without any other operations.
To add or delete one rule, driver needs to config TCAM and Profile,
build training packets which contains the input set value, and send
the training packets through FDIR Tx queue. In addition, driver needs to
manage the software context to avoid adding duplicated rules, deleting
non-existent rule, input set conflicts and other invalid cases.
NOTE:
Supported pattern/actions and their parse functions are not be included in
this patch, they will be added in a separate one.
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
Signed-off-by: Simei Su <simei.su@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Tested-by: Chen Bo <BoX.C.Chen@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-03-09 11:08:04 +08:00
|
|
|
#include "ice_virtchnl_fdir.h"
|
2018-09-19 17:42:55 -07:00
|
|
|
|
2018-09-19 17:43:01 -07:00
|
|
|
/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */
|
|
|
|
#define ICE_MAX_VLAN_PER_VF 8
|
2020-05-15 17:51:18 -07:00
|
|
|
/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for
|
|
|
|
* broadcast, and 16 for additional unicast/multicast filters
|
|
|
|
*/
|
|
|
|
#define ICE_MAX_MACADDR_PER_VF 18
|
2018-09-19 17:43:01 -07:00
|
|
|
|
|
|
|
/* Malicious Driver Detection */
|
2018-09-19 17:42:59 -07:00
|
|
|
#define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
|
2019-07-25 02:53:58 -07:00
|
|
|
#define ICE_MDD_EVENTS_THRESHOLD 30
|
2018-09-19 17:42:58 -07:00
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
/* Static VF transaction/status register def */
|
|
|
|
#define VF_DEVICE_STATUS 0xAA
|
|
|
|
#define VF_TRANS_PENDING_M 0x20
|
|
|
|
|
2019-07-25 01:55:37 -07:00
|
|
|
/* wait defines for polling PF_PCI_CIAD register status */
|
|
|
|
#define ICE_PCI_CIAD_WAIT_COUNT 100
|
|
|
|
#define ICE_PCI_CIAD_WAIT_DELAY_US 1
|
|
|
|
|
2020-02-27 10:14:52 -08:00
|
|
|
/* VF resource constraints */
|
2019-07-25 01:55:39 -07:00
|
|
|
#define ICE_MAX_VF_COUNT 256
|
|
|
|
#define ICE_MIN_QS_PER_VF 1
|
|
|
|
#define ICE_NONQ_VECS_VF 1
|
|
|
|
#define ICE_MAX_SCATTER_QS_PER_VF 16
|
2020-02-27 10:14:52 -08:00
|
|
|
#define ICE_MAX_RSS_QS_PER_VF 16
|
|
|
|
#define ICE_NUM_VF_MSIX_MED 17
|
|
|
|
#define ICE_NUM_VF_MSIX_SMALL 5
|
2020-07-29 17:19:16 -07:00
|
|
|
#define ICE_NUM_VF_MSIX_MULTIQ_MIN 3
|
2019-07-25 01:55:39 -07:00
|
|
|
#define ICE_MIN_INTR_PER_VF (ICE_MIN_QS_PER_VF + 1)
|
2020-02-18 13:22:06 -08:00
|
|
|
#define ICE_MAX_VF_RESET_TRIES 40
|
|
|
|
#define ICE_MAX_VF_RESET_SLEEP_MS 20
|
2019-07-25 01:55:39 -07:00
|
|
|
|
2019-12-12 03:12:56 -08:00
|
|
|
#define ice_for_each_vf(pf, i) \
|
|
|
|
for ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)
|
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
/* Specific VF states */
|
|
|
|
enum ice_vf_states {
|
2019-08-02 01:25:20 -07:00
|
|
|
ICE_VF_STATE_INIT = 0, /* PF is initializing VF */
|
|
|
|
ICE_VF_STATE_ACTIVE, /* VF resources are allocated for use */
|
|
|
|
ICE_VF_STATE_QS_ENA, /* VF queue(s) enabled */
|
2018-09-19 17:42:55 -07:00
|
|
|
ICE_VF_STATE_DIS,
|
|
|
|
ICE_VF_STATE_MC_PROMISC,
|
|
|
|
ICE_VF_STATE_UC_PROMISC,
|
|
|
|
ICE_VF_STATES_NBITS
|
|
|
|
};
|
|
|
|
|
|
|
|
/* VF capabilities */
|
|
|
|
enum ice_virtchnl_cap {
|
|
|
|
ICE_VIRTCHNL_VF_CAP_L2 = 0,
|
|
|
|
ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
|
|
|
|
};
|
|
|
|
|
2020-09-17 13:13:34 -07:00
|
|
|
struct ice_time_mac {
|
|
|
|
unsigned long time_modified;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
};
|
|
|
|
|
2020-02-13 13:31:16 -08:00
|
|
|
/* VF MDD events print structure */
|
|
|
|
struct ice_mdd_vf_events {
|
|
|
|
u16 count; /* total count of Rx|Tx events */
|
|
|
|
/* count number of the last printed event */
|
|
|
|
u16 last_printed;
|
|
|
|
};
|
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
/* VF information structure */
|
|
|
|
struct ice_vf {
|
|
|
|
struct ice_pf *pf;
|
|
|
|
|
2020-05-07 17:41:06 -07:00
|
|
|
u16 vf_id; /* VF ID in the PF space */
|
ice: Reorganize ice_vf struct
The ice_vf struct can be used hundreds of times in our
driver so it pays to use less memory per struct.
ice_vf prior to this commit:
/* size: 112, cachelines: 2, members: 25 */
/* sum members: 101, holes: 4, sum holes: 8 */
/* bit holes: 2, sum bit holes: 11 bits */
/* padding: 3 */
/* last cacheline: 48 bytes */
ice_vf after this commit:
/* size: 104, cachelines: 2, members: 25 */
/* sum members: 100, holes: 3, sum holes: 4 */
/* bit holes: 1, sum bit holes: 3 bits */
/* last cacheline: 40 bytes */
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:24:36 -07:00
|
|
|
u16 lan_vsi_idx; /* index into PF struct */
|
2021-03-09 11:08:03 +08:00
|
|
|
u16 ctrl_vsi_idx;
|
ice: Enable FDIR Configure for AVF
The virtual channel is going to be extended to support FDIR and
RSS configure from AVF. New data structures and OP codes will be
added, the patch enable the FDIR part.
To support above advanced AVF feature, we need to figure out
what kind of data structure should be passed from VF to PF to describe
an FDIR rule or RSS config rule. The common part of the requirement is
we need a data structure to represent the input set selection of a rule's
hash key.
An input set selection is a group of fields be selected from one or more
network protocol layers that could be identified as a specific flow.
For example, select dst IP address from an IPv4 header combined with
dst port from the TCP header as the input set for an IPv4/TCP flow.
The patch adds a new data structure virtchnl_proto_hdrs to abstract
a network protocol headers group which is composed of layers of network
protocol header(virtchnl_proto_hdr).
A protocol header contains a 32 bits mask (field_selector) to describe
which fields are selected as input sets, as well as a header type
(enum virtchnl_proto_hdr_type). Each bit is mapped to a field in
enum virtchnl_proto_hdr_field guided by its header type.
+------------+-----------+------------------------------+
| | Proto Hdr | Header Type A |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
|Proto Hdrs | Proto Hdr | Header Type B |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | Proto Hdr | Header Type C |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | .... |
+-------------------------------------------------------+
All fields in enum virtchnl_proto_hdr_fields are grouped with header type
and the value of the first field of a header type is always 32 aligned.
enum proto_hdr_type {
header_type_A = 0;
header_type_B = 1;
....
}
enum proto_hdr_field {
/* header type A */
header_A_field_0 = 0,
header_A_field_1 = 1,
header_A_field_2 = 2,
header_A_field_3 = 3,
/* header type B */
header_B_field_0 = 32, // = header_type_B << 5
header_B_field_0 = 33,
header_B_field_0 = 34
header_B_field_0 = 35,
....
};
So we have:
proto_hdr_type = proto_hdr_field / 32
bit offset = proto_hdr_field % 32
To simply the protocol header's operations, couple help macros are added.
For example, to select src IP and dst port as input set for an IPv4/UDP
flow.
we have:
struct virtchnl_proto_hdr hdr[2];
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[0], IPV4)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[0], IPV4, SRC)
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[1], UDP)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[1], UDP, DST)
The byte array is used to store the protocol header of a training package.
The byte array must be network order.
The patch added virtual channel support for iAVF FDIR add/validate/delete
filter. iAVF FDIR is Flow Director for Intel Adaptive Virtual Function
which can direct Ethernet packets to the queues of the Network Interface
Card. Add/delete command is adding or deleting one rule for each virtual
channel message, while validate command is just verifying if this rule
is valid without any other operations.
To add or delete one rule, driver needs to config TCAM and Profile,
build training packets which contains the input set value, and send
the training packets through FDIR Tx queue. In addition, driver needs to
manage the software context to avoid adding duplicated rules, deleting
non-existent rule, input set conflicts and other invalid cases.
NOTE:
Supported pattern/actions and their parse functions are not be included in
this patch, they will be added in a separate one.
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
Signed-off-by: Simei Su <simei.su@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Tested-by: Chen Bo <BoX.C.Chen@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-03-09 11:08:04 +08:00
|
|
|
struct ice_vf_fdir fdir;
|
2019-07-25 01:55:36 -07:00
|
|
|
/* first vector index of this VF in the PF space */
|
|
|
|
int first_vector_idx;
|
2019-02-19 15:04:13 -08:00
|
|
|
struct ice_sw *vf_sw_id; /* switch ID the VF VSIs connect to */
|
2018-09-19 17:42:59 -07:00
|
|
|
struct virtchnl_version_info vf_ver;
|
ice: Reorganize ice_vf struct
The ice_vf struct can be used hundreds of times in our
driver so it pays to use less memory per struct.
ice_vf prior to this commit:
/* size: 112, cachelines: 2, members: 25 */
/* sum members: 101, holes: 4, sum holes: 8 */
/* bit holes: 2, sum bit holes: 11 bits */
/* padding: 3 */
/* last cacheline: 48 bytes */
ice_vf after this commit:
/* size: 104, cachelines: 2, members: 25 */
/* sum members: 100, holes: 3, sum holes: 4 */
/* bit holes: 1, sum bit holes: 3 bits */
/* last cacheline: 40 bytes */
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:24:36 -07:00
|
|
|
u32 driver_caps; /* reported by VF driver */
|
2020-09-17 13:13:35 -07:00
|
|
|
struct virtchnl_ether_addr dev_lan_addr;
|
2020-09-17 13:13:34 -07:00
|
|
|
struct virtchnl_ether_addr hw_lan_addr;
|
|
|
|
struct ice_time_mac legacy_last_added_umac;
|
2020-02-27 10:14:52 -08:00
|
|
|
DECLARE_BITMAP(txq_ena, ICE_MAX_RSS_QS_PER_VF);
|
|
|
|
DECLARE_BITMAP(rxq_ena, ICE_MAX_RSS_QS_PER_VF);
|
2020-01-22 07:21:25 -08:00
|
|
|
u16 port_vlan_info; /* Port VLAN ID and QoS */
|
2019-04-16 10:24:35 -07:00
|
|
|
u8 pf_set_mac:1; /* VF MAC address set by VMM admin */
|
|
|
|
u8 trusted:1;
|
ice: Reorganize ice_vf struct
The ice_vf struct can be used hundreds of times in our
driver so it pays to use less memory per struct.
ice_vf prior to this commit:
/* size: 112, cachelines: 2, members: 25 */
/* sum members: 101, holes: 4, sum holes: 8 */
/* bit holes: 2, sum bit holes: 11 bits */
/* padding: 3 */
/* last cacheline: 48 bytes */
ice_vf after this commit:
/* size: 104, cachelines: 2, members: 25 */
/* sum members: 100, holes: 3, sum holes: 4 */
/* bit holes: 1, sum bit holes: 3 bits */
/* last cacheline: 40 bytes */
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:24:36 -07:00
|
|
|
u8 spoofchk:1;
|
|
|
|
u8 link_forced:1;
|
|
|
|
u8 link_up:1; /* only valid if VF link is forced */
|
|
|
|
/* VSI indices - actual VSI pointers are maintained in the PF structure
|
|
|
|
* When assigned, these will be non-zero, because VSI 0 is always
|
|
|
|
* the main LAN VSI for the PF.
|
|
|
|
*/
|
2018-09-19 17:42:55 -07:00
|
|
|
u16 lan_vsi_num; /* ID as used by firmware */
|
ice: Reorganize ice_vf struct
The ice_vf struct can be used hundreds of times in our
driver so it pays to use less memory per struct.
ice_vf prior to this commit:
/* size: 112, cachelines: 2, members: 25 */
/* sum members: 101, holes: 4, sum holes: 8 */
/* bit holes: 2, sum bit holes: 11 bits */
/* padding: 3 */
/* last cacheline: 48 bytes */
ice_vf after this commit:
/* size: 104, cachelines: 2, members: 25 */
/* sum members: 100, holes: 3, sum holes: 4 */
/* bit holes: 1, sum bit holes: 3 bits */
/* last cacheline: 40 bytes */
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:24:36 -07:00
|
|
|
unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
|
|
|
|
DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS); /* VF runtime states */
|
|
|
|
|
2018-09-19 17:42:59 -07:00
|
|
|
u64 num_inval_msgs; /* number of continuous invalid msgs */
|
|
|
|
u64 num_valid_msgs; /* number of valid msgs detected */
|
2019-02-19 15:04:13 -08:00
|
|
|
unsigned long vf_caps; /* VF's adv. capabilities */
|
ice: Reorganize ice_vf struct
The ice_vf struct can be used hundreds of times in our
driver so it pays to use less memory per struct.
ice_vf prior to this commit:
/* size: 112, cachelines: 2, members: 25 */
/* sum members: 101, holes: 4, sum holes: 8 */
/* bit holes: 2, sum bit holes: 11 bits */
/* padding: 3 */
/* last cacheline: 48 bytes */
ice_vf after this commit:
/* size: 104, cachelines: 2, members: 25 */
/* sum members: 100, holes: 3, sum holes: 4 */
/* bit holes: 1, sum bit holes: 3 bits */
/* last cacheline: 40 bytes */
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:24:36 -07:00
|
|
|
u8 num_req_qs; /* num of queue pairs requested by VF */
|
2018-09-19 17:42:55 -07:00
|
|
|
u16 num_mac;
|
2019-02-26 16:35:09 -08:00
|
|
|
u16 num_vf_qs; /* num of queue configured per VF */
|
2020-02-13 13:31:16 -08:00
|
|
|
struct ice_mdd_vf_events mdd_rx_events;
|
|
|
|
struct ice_mdd_vf_events mdd_tx_events;
|
2021-03-02 10:12:01 -08:00
|
|
|
DECLARE_BITMAP(opcodes_allowlist, VIRTCHNL_OP_MAX);
|
2018-09-19 17:42:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI_IOV
|
2018-09-19 17:42:57 -07:00
|
|
|
void ice_process_vflr_event(struct ice_pf *pf);
|
2018-09-19 17:42:55 -07:00
|
|
|
int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
|
2018-09-19 17:42:58 -07:00
|
|
|
int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
|
2019-02-26 16:35:11 -08:00
|
|
|
int
|
|
|
|
ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi);
|
2018-09-19 17:42:58 -07:00
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
void ice_free_vfs(struct ice_pf *pf);
|
2018-09-19 17:42:59 -07:00
|
|
|
void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
|
2018-09-19 17:43:00 -07:00
|
|
|
void ice_vc_notify_link_state(struct ice_pf *pf);
|
2018-09-19 17:42:57 -07:00
|
|
|
void ice_vc_notify_reset(struct ice_pf *pf);
|
2018-09-19 17:42:55 -07:00
|
|
|
bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);
|
2020-02-13 13:31:16 -08:00
|
|
|
bool ice_reset_vf(struct ice_vf *vf, bool is_vflr);
|
2020-07-13 13:53:07 -07:00
|
|
|
void ice_restore_all_vfs_msi_state(struct pci_dev *pdev);
|
2021-03-02 10:12:00 -08:00
|
|
|
bool
|
|
|
|
ice_is_malicious_vf(struct ice_pf *pf, struct ice_rq_event_info *event,
|
|
|
|
u16 num_msg_proc, u16 num_msg_pending);
|
2018-09-19 17:42:58 -07:00
|
|
|
|
2019-02-26 16:35:11 -08:00
|
|
|
int
|
|
|
|
ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
|
|
|
|
__be16 vlan_proto);
|
2018-09-19 17:42:58 -07:00
|
|
|
|
|
|
|
int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
|
|
|
|
|
|
|
|
int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
|
|
|
|
|
|
|
|
int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
|
ice: Refactor interrupt tracking
Currently we have two MSI-x (IRQ) trackers, one for OS requested MSI-x
entries (sw_irq_tracker) and one for hardware MSI-x vectors
(hw_irq_tracker). Generally the sw_irq_tracker has less entries than the
hw_irq_tracker because the hw_irq_tracker has entries equal to the max
allowed MSI-x per PF and the sw_irq_tracker is mainly the minimum (non
SR-IOV portion of the vectors, kernel granted IRQs). All of the non
SR-IOV portions of the driver (i.e. LAN queues, RDMA queues, OICR, etc.)
take at least one of each type of tracker resource. SR-IOV only grabs
entries from the hw_irq_tracker. There are a few issues with this approach
that can be seen when doing any kind of device reconfiguration (i.e.
ethtool -L, SR-IOV, etc.). One of them being, any time the driver creates
an ice_q_vector and associates it to a LAN queue pair it will grab and
use one entry from the hw_irq_tracker and one from the sw_irq_tracker.
If the indices on these does not match it will cause a Tx timeout, which
will cause a reset and then the indices will match up again and traffic
will resume. The mismatched indices come from the trackers not being the
same size and/or the search_hint in the two trackers not being equal.
Another reason for the refactor is the co-existence of features with
SR-IOV. If SR-IOV is enabled and the interrupts are taken from the end
of the sw_irq_tracker then other features can no longer use this space
because the hardware has now given the remaining interrupts to SR-IOV.
This patch reworks how we track MSI-x vectors by removing the
hw_irq_tracker completely and instead MSI-x resources needed for SR-IOV
are determined all at once instead of per VF. This can be done because
when creating VFs we know how many are wanted and how many MSI-x vectors
each VF needs. This also allows us to start using MSI-x resources from
the end of the PF's allowed MSI-x vectors so we are less likely to use
entries needed for other features (i.e. RDMA, L2 Offload, etc).
This patch also reworks the ice_res_tracker structure by removing the
search_hint and adding a new member - "end". Instead of having a
search_hint we will always search from 0. The new member, "end", will be
used to manipulate the end of the ice_res_tracker (specifically
sw_irq_tracker) during runtime based on MSI-x vectors needed by SR-IOV.
In the normal case, the end of ice_res_tracker will be equal to the
ice_res_tracker's num_entries.
The sriov_base_vector member was added to the PF structure. It is used
to represent the starting MSI-x index of all the needed MSI-x vectors
for all SR-IOV VFs. Depending on how many MSI-x are needed, SR-IOV may
have to take resources from the sw_irq_tracker. This is done by setting
the sw_irq_tracker->end equal to the pf->sriov_base_vector. When all
SR-IOV VFs are removed then the sw_irq_tracker->end is reset back to
sw_irq_tracker->num_entries. The sriov_base_vector, along with the VF's
number of MSI-x (pf->num_vf_msix), vf_id, and the base MSI-x index on
the PF (pf->hw.func_caps.common_cap.msix_vector_first_id), is used to
calculate the first HW absolute MSI-x index for each VF, which is used
to write to the VPINT_ALLOC[_PCI] and GLINT_VECT2FUNC registers to
program the VFs MSI-x PCI configuration bits. Also, the sriov_base_vector
is used along with VF's num_vf_msix, vf_id, and q_vector->v_idx to
determine the MSI-x register index (used for writing to GLINT_DYN_CTL)
within the PF's space.
Interrupt changes removed any references to hw_base_vector, hw_oicr_idx,
and hw_irq_tracker. Only sw_base_vector, sw_oicr_idx, and sw_irq_tracker
variables remain. Change all of these by removing the "sw_" prefix to
help avoid confusion with these variables and their use.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:30:44 -07:00
|
|
|
|
|
|
|
int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
|
2019-08-02 01:25:20 -07:00
|
|
|
|
|
|
|
void ice_set_vf_state_qs_dis(struct ice_vf *vf);
|
2019-11-08 06:23:28 -08:00
|
|
|
int
|
|
|
|
ice_get_vf_stats(struct net_device *netdev, int vf_id,
|
|
|
|
struct ifla_vf_stats *vf_stats);
|
2020-05-07 17:40:59 -07:00
|
|
|
bool ice_is_any_vf_in_promisc(struct ice_pf *pf);
|
2020-01-22 07:21:31 -08:00
|
|
|
void
|
|
|
|
ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event);
|
2020-02-13 13:31:16 -08:00
|
|
|
void ice_print_vfs_mdd_events(struct ice_pf *pf);
|
2020-05-15 17:36:31 -07:00
|
|
|
void ice_print_vf_rx_mdd_event(struct ice_vf *vf);
|
2021-03-09 11:08:03 +08:00
|
|
|
struct ice_vsi *ice_vf_ctrl_vsi_setup(struct ice_vf *vf);
|
ice: Enable FDIR Configure for AVF
The virtual channel is going to be extended to support FDIR and
RSS configure from AVF. New data structures and OP codes will be
added, the patch enable the FDIR part.
To support above advanced AVF feature, we need to figure out
what kind of data structure should be passed from VF to PF to describe
an FDIR rule or RSS config rule. The common part of the requirement is
we need a data structure to represent the input set selection of a rule's
hash key.
An input set selection is a group of fields be selected from one or more
network protocol layers that could be identified as a specific flow.
For example, select dst IP address from an IPv4 header combined with
dst port from the TCP header as the input set for an IPv4/TCP flow.
The patch adds a new data structure virtchnl_proto_hdrs to abstract
a network protocol headers group which is composed of layers of network
protocol header(virtchnl_proto_hdr).
A protocol header contains a 32 bits mask (field_selector) to describe
which fields are selected as input sets, as well as a header type
(enum virtchnl_proto_hdr_type). Each bit is mapped to a field in
enum virtchnl_proto_hdr_field guided by its header type.
+------------+-----------+------------------------------+
| | Proto Hdr | Header Type A |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
|Proto Hdrs | Proto Hdr | Header Type B |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | Proto Hdr | Header Type C |
| | +------------------------------+
| | | BIT 31 | ... | BIT 1 | BIT 0 |
| |-----------+------------------------------+
| | .... |
+-------------------------------------------------------+
All fields in enum virtchnl_proto_hdr_fields are grouped with header type
and the value of the first field of a header type is always 32 aligned.
enum proto_hdr_type {
header_type_A = 0;
header_type_B = 1;
....
}
enum proto_hdr_field {
/* header type A */
header_A_field_0 = 0,
header_A_field_1 = 1,
header_A_field_2 = 2,
header_A_field_3 = 3,
/* header type B */
header_B_field_0 = 32, // = header_type_B << 5
header_B_field_0 = 33,
header_B_field_0 = 34
header_B_field_0 = 35,
....
};
So we have:
proto_hdr_type = proto_hdr_field / 32
bit offset = proto_hdr_field % 32
To simply the protocol header's operations, couple help macros are added.
For example, to select src IP and dst port as input set for an IPv4/UDP
flow.
we have:
struct virtchnl_proto_hdr hdr[2];
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[0], IPV4)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[0], IPV4, SRC)
VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[1], UDP)
VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[1], UDP, DST)
The byte array is used to store the protocol header of a training package.
The byte array must be network order.
The patch added virtual channel support for iAVF FDIR add/validate/delete
filter. iAVF FDIR is Flow Director for Intel Adaptive Virtual Function
which can direct Ethernet packets to the queues of the Network Interface
Card. Add/delete command is adding or deleting one rule for each virtual
channel message, while validate command is just verifying if this rule
is valid without any other operations.
To add or delete one rule, driver needs to config TCAM and Profile,
build training packets which contains the input set value, and send
the training packets through FDIR Tx queue. In addition, driver needs to
manage the software context to avoid adding duplicated rules, deleting
non-existent rule, input set conflicts and other invalid cases.
NOTE:
Supported pattern/actions and their parse functions are not be included in
this patch, they will be added in a separate one.
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
Signed-off-by: Simei Su <simei.su@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Tested-by: Chen Bo <BoX.C.Chen@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2021-03-09 11:08:04 +08:00
|
|
|
int
|
|
|
|
ice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode,
|
|
|
|
enum virtchnl_status_code v_retval, u8 *msg, u16 msglen);
|
|
|
|
bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id);
|
2018-09-19 17:42:55 -07:00
|
|
|
#else /* CONFIG_PCI_IOV */
|
2021-05-06 08:39:56 -07:00
|
|
|
static inline void ice_process_vflr_event(struct ice_pf *pf) { }
|
|
|
|
static inline void ice_free_vfs(struct ice_pf *pf) { }
|
|
|
|
static inline
|
|
|
|
void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) { }
|
|
|
|
static inline void ice_vc_notify_link_state(struct ice_pf *pf) { }
|
|
|
|
static inline void ice_vc_notify_reset(struct ice_pf *pf) { }
|
|
|
|
static inline void ice_set_vf_state_qs_dis(struct ice_vf *vf) { }
|
|
|
|
static inline
|
|
|
|
void ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) { }
|
|
|
|
static inline void ice_print_vfs_mdd_events(struct ice_pf *pf) { }
|
|
|
|
static inline void ice_print_vf_rx_mdd_event(struct ice_vf *vf) { }
|
|
|
|
static inline void ice_restore_all_vfs_msi_state(struct pci_dev *pdev) { }
|
2018-09-19 17:43:00 -07:00
|
|
|
|
2021-03-02 10:12:00 -08:00
|
|
|
static inline bool
|
|
|
|
ice_is_malicious_vf(struct ice_pf __always_unused *pf,
|
|
|
|
struct ice_rq_event_info __always_unused *event,
|
|
|
|
u16 __always_unused num_msg_proc,
|
|
|
|
u16 __always_unused num_msg_pending)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
static inline bool
|
|
|
|
ice_reset_all_vfs(struct ice_pf __always_unused *pf,
|
|
|
|
bool __always_unused is_vflr)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-13 13:31:16 -08:00
|
|
|
static inline bool
|
|
|
|
ice_reset_vf(struct ice_vf __always_unused *vf, bool __always_unused is_vflr)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-19 17:42:55 -07:00
|
|
|
static inline int
|
|
|
|
ice_sriov_configure(struct pci_dev __always_unused *pdev,
|
|
|
|
int __always_unused num_vfs)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2018-09-19 17:42:58 -07:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_set_vf_mac(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id, u8 __always_unused *mac)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_get_vf_cfg(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id,
|
|
|
|
struct ifla_vf_info __always_unused *ivi)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_set_vf_trust(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id, bool __always_unused trusted)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id, u16 __always_unused vid,
|
|
|
|
u8 __always_unused qos, __be16 __always_unused v_proto)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id, bool __always_unused ena)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_set_vf_link_state(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id, int __always_unused link_state)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
ice: Refactor interrupt tracking
Currently we have two MSI-x (IRQ) trackers, one for OS requested MSI-x
entries (sw_irq_tracker) and one for hardware MSI-x vectors
(hw_irq_tracker). Generally the sw_irq_tracker has less entries than the
hw_irq_tracker because the hw_irq_tracker has entries equal to the max
allowed MSI-x per PF and the sw_irq_tracker is mainly the minimum (non
SR-IOV portion of the vectors, kernel granted IRQs). All of the non
SR-IOV portions of the driver (i.e. LAN queues, RDMA queues, OICR, etc.)
take at least one of each type of tracker resource. SR-IOV only grabs
entries from the hw_irq_tracker. There are a few issues with this approach
that can be seen when doing any kind of device reconfiguration (i.e.
ethtool -L, SR-IOV, etc.). One of them being, any time the driver creates
an ice_q_vector and associates it to a LAN queue pair it will grab and
use one entry from the hw_irq_tracker and one from the sw_irq_tracker.
If the indices on these does not match it will cause a Tx timeout, which
will cause a reset and then the indices will match up again and traffic
will resume. The mismatched indices come from the trackers not being the
same size and/or the search_hint in the two trackers not being equal.
Another reason for the refactor is the co-existence of features with
SR-IOV. If SR-IOV is enabled and the interrupts are taken from the end
of the sw_irq_tracker then other features can no longer use this space
because the hardware has now given the remaining interrupts to SR-IOV.
This patch reworks how we track MSI-x vectors by removing the
hw_irq_tracker completely and instead MSI-x resources needed for SR-IOV
are determined all at once instead of per VF. This can be done because
when creating VFs we know how many are wanted and how many MSI-x vectors
each VF needs. This also allows us to start using MSI-x resources from
the end of the PF's allowed MSI-x vectors so we are less likely to use
entries needed for other features (i.e. RDMA, L2 Offload, etc).
This patch also reworks the ice_res_tracker structure by removing the
search_hint and adding a new member - "end". Instead of having a
search_hint we will always search from 0. The new member, "end", will be
used to manipulate the end of the ice_res_tracker (specifically
sw_irq_tracker) during runtime based on MSI-x vectors needed by SR-IOV.
In the normal case, the end of ice_res_tracker will be equal to the
ice_res_tracker's num_entries.
The sriov_base_vector member was added to the PF structure. It is used
to represent the starting MSI-x index of all the needed MSI-x vectors
for all SR-IOV VFs. Depending on how many MSI-x are needed, SR-IOV may
have to take resources from the sw_irq_tracker. This is done by setting
the sw_irq_tracker->end equal to the pf->sriov_base_vector. When all
SR-IOV VFs are removed then the sw_irq_tracker->end is reset back to
sw_irq_tracker->num_entries. The sriov_base_vector, along with the VF's
number of MSI-x (pf->num_vf_msix), vf_id, and the base MSI-x index on
the PF (pf->hw.func_caps.common_cap.msix_vector_first_id), is used to
calculate the first HW absolute MSI-x index for each VF, which is used
to write to the VPINT_ALLOC[_PCI] and GLINT_VECT2FUNC registers to
program the VFs MSI-x PCI configuration bits. Also, the sriov_base_vector
is used along with VF's num_vf_msix, vf_id, and q_vector->v_idx to
determine the MSI-x register index (used for writing to GLINT_DYN_CTL)
within the PF's space.
Interrupt changes removed any references to hw_base_vector, hw_oicr_idx,
and hw_irq_tracker. Only sw_base_vector, sw_oicr_idx, and sw_irq_tracker
variables remain. Change all of these by removing the "sw_" prefix to
help avoid confusion with these variables and their use.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2019-04-16 10:30:44 -07:00
|
|
|
static inline int
|
|
|
|
ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
|
|
|
|
struct ice_q_vector __always_unused *q_vector)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2019-11-08 06:23:28 -08:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
ice_get_vf_stats(struct net_device __always_unused *netdev,
|
|
|
|
int __always_unused vf_id,
|
|
|
|
struct ifla_vf_stats __always_unused *vf_stats)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2020-05-07 17:40:59 -07:00
|
|
|
|
|
|
|
static inline bool ice_is_any_vf_in_promisc(struct ice_pf __always_unused *pf)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-19 17:42:55 -07:00
|
|
|
#endif /* CONFIG_PCI_IOV */
|
|
|
|
#endif /* _ICE_VIRTCHNL_PF_H_ */
|