Add switchdev driver model for ice driver
Subsystems (2)
v3 cover Add switchdev driver model for ice driver
The following patch series introduces basic switchdev model support in ice driver. Implement the following blocks of switchdev framework:
- VF port representors creation
- control plane VSI definition
- exception path (a. k. a. "slow-path") - to allow a virtual switch or linux bridge to receive any packet that doesn't match any hw filter
- link state management of virtual ports
- query virtual port statistics
Hardware offload support in switchdev mode is out of scope of this patchset. Devlink interface is used to toggle between switchdev and legacy (the default) modes of the driver.
Changelog:
v3:
* add more info to Kconfig ICE_SWITCHDEV flag
* correct spealing
v2:
* fix build issue in ice: set and release switchdev environment by moving call of ice_vsi_setup to next patch which have definition of switchdev VSI
Grzegorz Nitka (5):
ice: set and release switchdev environment
ice: introduce new type of VSI for switchdev
ice: enable/disable switchdev when managing VFs
ice: rebuild switchdev when resetting all VFs
ice: switchdev slow path
Michal Swiatkowski (5):
ice: support basic E-Switch mode control
ice: introduce VF port representor
ice: allow process vf opcodes in different ways
ice: manage VSI antispoof and destination override
ice: allow changing lan_en and lb_en on dflt rules
Wojciech Drewek (2):
ice: Move devlink port to PF/VF struct
ice: add port representor ethtool ops and stats
drivers/net/ethernet/intel/Kconfig | 14 + drivers/net/ethernet/intel/ice/Makefile | 4 +- drivers/net/ethernet/intel/ice/ice.h | 48 +- drivers/net/ethernet/intel/ice/ice_base.c | 37 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 109 ++- drivers/net/ethernet/intel/ice/ice_devlink.h | 6 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 656 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 82 +++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 32 +- drivers/net/ethernet/intel/ice/ice_fltr.c | 80 +++ drivers/net/ethernet/intel/ice/ice_fltr.h | 7 + .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 43 ++ drivers/net/ethernet/intel/ice/ice_lib.c | 112 ++- drivers/net/ethernet/intel/ice/ice_lib.h | 11 + drivers/net/ethernet/intel/ice/ice_main.c | 47 +- drivers/net/ethernet/intel/ice/ice_repr.c | 329 +++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 27 + drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.h | 6 + drivers/net/ethernet/intel/ice/ice_txrx.c | 3 + drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 4 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 196 +++++- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 45 ++ 24 files changed, 1821 insertions(+), 80 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch.c create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch.h create mode 100644 drivers/net/ethernet/intel/ice/ice_repr.c create mode 100644 drivers/net/ethernet/intel/ice/ice_repr.h
Signature · 1 line
2.30.2
PATCH v3 1/12 ice: support basic E-Switch mode control
Write set and get eswitch mode functions used by devlink ops. Use new pf struct member eswitch_mode to track current eswitch mode in driver.
Changing eswitch mode is only allowed when there are no VFs created.
Create new file for eswitch related code.
Add config flag ICE_SWITCHDEV to allow user to choose if switchdev support should be enabled or disabled.
Use case examples:
- show current eswitch mode ('legacy' is the default one) [root at localhost]# devlink dev eswitch show pci/0000:03:00.1 pci/0000:03:00.1: mode legacy
- move to 'switchdev' mode
[root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode switchdev
[root at localhost]# devlink dev eswitch show pci/0000:03:00.1 pci/0000:03:00.1: mode switchdev
- create 2 VFs
[root at localhost]# echo 2 > /sys/class/net/ens4f1/device/sriov_numvfs
- unsuccessful attempt to change eswitch mode while VFs are created [root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode legacy devlink answers: Operation not supported
- destroy VFs
[root at localhost]# echo 0 > /sys/class/net/ens4f1/device/sriov_numvfs
- restore 'legacy' mode
[root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode legacy [root at localhost]# devlink dev eswitch show pci/0000:03:00.1 pci/0000:03:00.1: mode legacy
--- drivers/net/ethernet/intel/Kconfig | 14 +++++ drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_devlink.c | 3 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 62 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 34 +++++++++++ 6 files changed, 115 insertions(+) create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch.c create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch.h
drivers/net/ethernet/intel/Kconfig +14 -0
@@ -313,6 +313,20 @@ config ICE To compile this driver as a module, choose M here. The module will be called ice. +config ICE_SWITCHDEV + bool "Switchdev Support" + default y + depends on ICE && NET_SWITCHDEV + help + Switchdev support provides internal SRIOV packet steering and switching. + + To enable it on running kernel use devlink tool: + #devlink dev eswitch set pci/0000:XX:XX.X mode switchdev + + Say Y here if you want to use Switchdev in the driver. + + If unsure, say N. + config FM10K tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support" default n
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -33,3 +33,4 @@ ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o +ice-$(CONFIG_ICE_SWITCHDEV) += ice_eswitch.o
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -430,6 +430,7 @@ struct ice_pf {struct ice_vsi **vsi;/* VSIs created by the driver */ struct ice_sw *first_sw;/* first switch created by firmware */ +u16 eswitch_mode;/* current mode of eswitch */ /* Virtchnl/SR-IOV config info */ struct ice_vf *vf;u16 num_alloc_vfs;/* actual number of VFs allocated */
drivers/net/ethernet/intel/ice/ice_devlink.c +3 -0
@@ -4,6 +4,7 @@#include "ice.h" #include "ice_lib.h" #include "ice_devlink.h" +#include "ice_eswitch.h" #include "ice_fw_update.h" /* context for devlink info version reporting */
@@ -423,6 +424,8 @@ ice_devlink_flash_update(struct devlink *devlink,static const struct devlink_ops ice_devlink_ops = { .supported_flash_update_params =DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK , + .eswitch_mode_get = ice_eswitch_mode_get, + .eswitch_mode_set = ice_eswitch_mode_set, .info_get = ice_devlink_info_get, .flash_update = ice_devlink_flash_update, };
drivers/net/ethernet/intel/ice/ice_eswitch.c new file +62 -0
62 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_eswitch.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_ESWITCH_H_ +#define _ICE_ESWITCH_H_ +#include <net/devlink.h> + +#ifdef CONFIG_ICE_SWITCHDEV +int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode); +int +ice_eswitch_mode_set (struct devlink *devlink,u16 mode, +struct netlink_ext_ack *extack); +bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf); +#else /* CONFIG_ICE_SWITCHDEV */ +static inline int +ice_eswitch_mode_get (struct devlink *devlink,u16 *mode) +{ +return DEVLINK_ESWITCH_MODE_LEGACY ; +} + +static inline int +ice_eswitch_mode_set (struct devlink *devlink,u16 mode, +struct netlink_ext_ack *extack) +{ +return -EOPNOTSUPP ; +} + +static inline bool +ice_is_eswitch_mode_switchdev (struct ice_pf *pf) +{ +return false; +} +#endif /* CONFIG_ICE_SWITCHDEV */ +#endif
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 1/12 ice: support basic E-Switch mode control
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 49 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 01/12] ice: support basic E- Switch mode control
Write set and get eswitch mode functions used by devlink ops. Use new pf struct member
eswitch_modeto track current eswitch mode in driver.Changing eswitch mode is only allowed when there are no VFs created.
Create new file for eswitch related code.
Add config flag
ICE_SWITCHDEVto allow user to choose if switchdev support should be enabled or disabled.Use case examples:
- show current eswitch mode ('legacy' is the default one) [root at localhost]# devlink dev eswitch show pci/0000:03:00.1
pci/0000:03:00.1: mode legacy- move to 'switchdev' mode
[root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode switchdev [root at localhost]# devlink dev eswitch show pci/0000:03:00.1 pci/0000:03:00.1: mode switchdev- create 2 VFs
[root at localhost]# echo 2 >/sys/class/net/ens4f1/device/sriov_numvfs- unsuccessful attempt to change eswitch mode while VFs are created [root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode legacy devlink answers: Operation not supported
- destroy VFs
[root at localhost]# echo 0 >/sys/class/net/ens4f1/device/sriov_numvfs- restore 'legacy' mode
[root at localhost]# devlink dev eswitch set pci/0000:03:00.1 mode legacy [root at localhost]# devlink dev eswitch show pci/0000:03:00.1 pci/0000:03:00.1: mode legacyCo-developed-by Grzegorz Nitka <[email protected]>Signed-off-by Grzegorz Nitka <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/Kconfig | 14 +++++ drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_devlink.c | 3 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 62 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 34 +++++++++++ 6 files changed, 115 insertions(+)
Quoted 3 lines
create mode 100644
drivers/net/ethernet/intel/ice/ice_eswitch.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_eswitch.h
PATCH v3 2/12 ice: Move devlink port to PF/VF struct
In reply to Michal SwiatkowskiFrom: Wojciech Drewek <[email protected]>
Keeping devlink port inside VSI data structure causes some issues. Since VF VSI is released during reset that means that we have to unregister devlink port and register it again every time reset is triggered. With the new changes in devlink API it
might cause deadlock issues. After calling devlink_port_register/devlink_port_unregister devlink API is going to lock rtnl_mutex. It's an issue when VF reset is triggered in netlink operation context (like setting VF MAC address or VLAN), because rtnl_lock is already taken by netlink. Another call of rtnl_lock from devlink API results in dead-lock.
By moving devlink port to PF/VF we avoid creating/destroying it during reset. Since this patch, devlink ports are created during ice_probe, destroyed during ice_remove for PF and created during ice_repr_add, destroyed during ice_repr_rem for VF.
--- drivers/net/ethernet/intel/ice/ice.h | 7 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 106 +++++++++++++----- drivers/net/ethernet/intel/ice/ice_devlink.h | 6 +- drivers/net/ethernet/intel/ice/ice_lib.c | 3 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 9 ++ 7 files changed, 100 insertions(+), 37 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +3 -4
@@ -302,10 +302,6 @@ struct ice_vsi {spinlock_t arfs_lock;/* protects aRFS hash table and filter state */ atomic_t *arfs_last_fltr_id; -/* devlink port data */ -struct devlink_port devlink_port; -bool devlink_port_registered; -u16 max_frame;u16 rx_buf_len;
@@ -417,6 +413,9 @@ struct ice_pf {struct devlink_region *nvm_region;struct devlink_region *devcaps_region; +/* devlink port data */ +struct devlink_port devlink_port; +/* OS reserved IRQ details */ struct msix_entry *msix_entries;struct ice_res_tracker *irq_tracker;
drivers/net/ethernet/intel/ice/ice_devlink.c +79 -27
140 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_devlink.h +4 -2
@@ -8,8 +8,10 @@ struct ice_pf *ice_allocate_pf(struct device *dev);int ice_devlink_register (struct ice_pf *pf);void ice_devlink_unregister (struct ice_pf *pf); -int ice_devlink_create_port (struct ice_vsi *vsi); -void ice_devlink_destroy_port (struct ice_vsi *vsi); +int ice_devlink_create_pf_port (struct ice_pf *pf); +void ice_devlink_destroy_pf_port (struct ice_pf *pf); +int ice_devlink_create_vf_port (struct ice_vf *vf); +void ice_devlink_destroy_vf_port (struct ice_vf *vf);void ice_devlink_init_regions (struct ice_pf *pf);void ice_devlink_destroy_regions (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_lib.c +2 -1
@@ -2856,7 +2856,8 @@ int ice_vsi_release(struct ice_vsi *vsi)clear_bit (ICE_VSI_NETDEV_REGISTERED , vsi->state); } -ice_devlink_destroy_port (vsi); +if (vsi->type ==ICE_VSI_PF ) +ice_devlink_destroy_pf_port (pf);if (test_bit (ICE_FLAG_RSS_ENA , pf->flags))ice_rss_clean (vsi);
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -4177,11 +4177,11 @@ static int ice_register_netdev(struct ice_pf *pf)set_bit (ICE_VSI_NETDEV_REGISTERED , vsi->state);netif_carrier_off (vsi->netdev);netif_tx_stop_all_queues (vsi->netdev); - err =ice_devlink_create_port (vsi); + err =ice_devlink_create_pf_port (pf);if (err) goto err_devlink_create; -devlink_port_type_eth_set (&vsi->devlink_port, vsi->netdev); +devlink_port_type_eth_set (&pf->devlink_port, vsi->netdev);return 0 ; err_devlink_create:
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +1 -1
@@ -251,7 +251,7 @@ ice_vc_hash_field_match_type ice_vc_hash_field_list_comms[] = {* ice_get_vf_vsi - get VF's VSI based on the stored index * @vf: VF used to get VSI */ -static struct ice_vsi *ice_get_vf_vsi (struct ice_vf *vf) +struct ice_vsi *ice_get_vf_vsi (struct ice_vf *vf) {return vf->pf->vsi[vf->lan_vsi_idx]; }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +9 -0
@@ -111,9 +111,13 @@ struct ice_vf {struct ice_mdd_vf_events mdd_rx_events;struct ice_mdd_vf_events mdd_tx_events;DECLARE_BITMAP (opcodes_allowlist,VIRTCHNL_OP_MAX ); + +/* devlink port data */ +struct devlink_port devlink_port; };#ifdef CONFIG_PCI_IOV +struct ice_vsi *ice_get_vf_vsi (struct ice_vf *vf);void ice_process_vflr_event (struct ice_pf *pf);int ice_sriov_configure (struct pci_dev *pdev,int num_vfs);int ice_set_vf_mac (struct net_device *netdev,int vf_id,u8 *mac);
@@ -171,6 +175,11 @@ 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) { } +static inline struct ice_vsi *ice_get_vf_vsi (struct ice_vf *vf) +{ +return NULL ; +} + static inline bool ice_is_malicious_vf(struct ice_pf __always_unused *pf, struct ice_rq_event_info __always_unused *event,
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 2/12 ice: Move devlink port to PF/VF struct
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 22 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 02/12] ice: Move devlink port to PF/VF struct
From: Wojciech Drewek <[email protected]>
Keeping devlink port inside VSI data structure causes some issues. Since VF VSI is released during reset that means that we have to unregister devlink port and register it again every time reset is triggered. With the new changes in devlink API it might cause deadlock issues. After calling devlink_port_register/devlink_port_unregister devlink API is going to lock
rtnl_mutex. It's an issue when VF reset is triggered in netlink operation context (like setting VF MAC address or VLAN), becausertnl_lockis already taken by netlink. Another call ofrtnl_lockfrom devlink API results in dead- lock.By moving devlink port to PF/VF we avoid creating/destroying it during reset. Since this patch, devlink ports are created during
ice_probe, destroyed duringice_removefor PF and created duringice_repr_add, destroyed duringice_repr_remfor VF.Signed-off-by Wojciech Drewek <[email protected]>---
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice.h | 7 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 106 +++++++++++++----- drivers/net/ethernet/intel/ice/ice_devlink.h | 6 +- drivers/net/ethernet/intel/ice/ice_lib.c | 3 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 9 ++ 7 files changed, 100 insertions(+), 37 deletions(-)
PATCH v3 3/12 ice: introduce VF port representor
In reply to Michal SwiatkowskiPort representor is used to manage VF from host side. To allow it each created representor registers netdevice with random hw address. Also devlink port is created for all representors.
Port representor name is created based on switch id or managed by devlink core if devlink port was registered with success.
Open and stop ndo ops are implemented to allow managing the VF link state. Link state is tracked in VF struct.
Struct ice_netdev_priv is extended by pointer to representor field. This is needed to get correct representor from netdev struct mostly used in ndo calls.
Implement helper functions to check if given netdev is netdev of port representor (ice_is_port_repr_netdev) and to get representor from netdev (ice_netdev_to_repr).
As driver mostly will create or destroy port representors on all VFs instead of on single one, write functions to add and remove representor for each VF.
Representor struct contains pointer to source VSI, which is VSI configured on VF, backpointer to VF, backpointer to netdev, q_vector pointer and metadata_dst which will be used in data path.
--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_repr.c | 254 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 22 ++ .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 4 + 6 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_repr.c create mode 100644 drivers/net/ethernet/intel/ice/ice_repr.h
drivers/net/ethernet/intel/ice/Makefile +2 -1
@@ -26,7 +26,8 @@ ice-y := ice_main.o \ ice_devlink.o \ ice_fw_update.o \ ice_lag.o \ - ice_ethtool.o + ice_ethtool.o \ + ice_repr.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_allowlist.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -63,6 +63,7 @@#include "ice_fdir.h" #include "ice_xsk.h" #include "ice_arfs.h" +#include "ice_repr.h" #include "ice_lag.h" #define ICE_BAR0 0
@@ -508,6 +509,7 @@ struct ice_pf {struct ice_netdev_priv {struct ice_vsi *vsi; +struct ice_repr *repr; };/**
drivers/net/ethernet/intel/ice/ice_repr.c new file +254 -0
254 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_repr.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2019-2021, Intel Corporation. */ + +#ifndef _ICE_REPR_H_ +#define _ICE_REPR_H_ +#include <net/dst_metadata.h> +#include "ice.h" + +struct ice_repr { +struct ice_vsi *src_vsi; +struct ice_vf *vf; +struct ice_q_vector *q_vector; +struct net_device *netdev; +struct metadata_dst *dst; +}; + +int ice_repr_add_for_all_vfs (struct ice_pf *pf); +void ice_repr_rem_from_all_vfs (struct ice_pf *pf); + +struct ice_repr *ice_netdev_to_repr (struct net_device *netdev); +bool ice_is_port_repr_netdev (struct net_device *netdev); +#endif
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +1 -1
@@ -381,7 +381,7 @@ static bool ice_is_vf_link_up(struct ice_vf *vf)* * send a link status message to a single VF */ -static void ice_vc_notify_vf_link_state (struct ice_vf *vf) +void ice_vc_notify_vf_link_state (struct ice_vf *vf) {struct virtchnl_pf_event pfe = {0 };struct ice_hw *hw = &vf->pf->hw;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +4 -0
@@ -112,6 +112,8 @@ struct ice_vf {struct ice_mdd_vf_events mdd_tx_events;DECLARE_BITMAP (opcodes_allowlist,VIRTCHNL_OP_MAX ); +struct ice_repr *repr; +/* devlink port data */ struct devlink_port devlink_port; };
@@ -128,6 +130,7 @@ void ice_free_vfs(struct ice_pf *pf);void ice_vc_process_vf_msg (struct ice_pf *pf,struct ice_rq_event_info *event);void ice_vc_notify_link_state (struct ice_pf *pf);void ice_vc_notify_reset (struct ice_pf *pf); +void ice_vc_notify_vf_link_state (struct ice_vf *vf);bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr);bool ice_reset_vf (struct ice_vf *vf,bool is_vflr);void ice_restore_all_vfs_msi_state (struct pci_dev *pdev);
@@ -168,6 +171,7 @@ static inlinevoid 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_vc_notify_vf_link_state (struct ice_vf *vf) { }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) { }
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 3/12 ice: introduce VF port representor
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 38 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 03/12] ice: introduce VF port representor
Port representor is used to manage VF from host side. To allow it each created representor registers netdevice with random hw address. Also devlink port is created for all representors.
Port representor name is created based on switch id or managed by devlink core if devlink port was registered with success.
Open and stop ndo ops are implemented to allow managing the VF link state. Link state is tracked in VF struct.
Struct
ice_netdev_privis extended by pointer to representor field. This is needed to get correct representor from netdev struct mostly used in ndo calls.Implement helper functions to check if given netdev is netdev of port representor (
ice_is_port_repr_netdev) and to get representor from netdev (ice_netdev_to_repr).As driver mostly will create or destroy port representors on all VFs instead of on single one, write functions to add and remove representor for each VF.
Representor struct contains pointer to source VSI, which is VSI configured on VF, backpointer to VF, backpointer to netdev,
q_vectorpointer andmetadata_dstwhich will be used in data path.Co-developed-by Grzegorz Nitka <[email protected]>Signed-off-by Grzegorz Nitka <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_repr.c | 254 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 22 ++ .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 4 + 6 files changed, 285 insertions(+), 2 deletions(-) create mode 100644
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_repr.c
create mode 100644drivers/net/ethernet/intel/ice/ice_repr.h
PATCH v3 4/12 ice: allow process vf opcodes in different ways
In reply to Michal SwiatkowskiIn switchdev driver shouldn't add MAC, VLAN and promisc filters on iavf demand but should return success to not break normal iavf flow.
Achieve that by creating table of functions pointer with default functions used to parse iavf command. While parse iavf command, call correct function from table instead of calling function direct.
When port representors are being created change functions in table to new one that behaves correctly for switchdev puprose (ignoring new filters).
Change back to default ops when representors are being removed.
--- drivers/net/ethernet/intel/ice/ice_repr.c | 23 ++- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 170 +++++++++++++++--- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 32 ++++ 3 files changed, 198 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice_repr.c +18 -5
@@ -228,15 +228,24 @@ int ice_repr_add_for_all_vfs(struct ice_pf *pf)int i;ice_for_each_vf (pf, i) { - err =ice_repr_add (&pf->vf[i]); +struct ice_vf *vf = &pf->vf[i]; + + err =ice_repr_add (vf);if (err) goto err; + +ice_vc_change_ops_to_repr (&vf->vc_ops); } +return 0 ; err: -for (i = i -1 ; i >=0 ; i--) -ice_repr_rem (&pf->vf[i]); +for (i = i -1 ; i >=0 ; i--) { +struct ice_vf *vf = &pf->vf[i]; + +ice_repr_rem (vf); +ice_vc_set_dflt_vf_ops (&vf->vc_ops); + }return err; }
@@ -249,6 +258,10 @@ void ice_repr_rem_from_all_vfs(struct ice_pf *pf) {int i; -ice_for_each_vf (pf, i) -ice_repr_rem (&pf->vf[i]); +ice_for_each_vf (pf, i) { +struct ice_vf *vf = &pf->vf[i]; + +ice_repr_rem (vf); +ice_vc_set_dflt_vf_ops (&vf->vc_ops); + } }
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +148 -22
247 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +32 -0
@@ -70,6 +70,32 @@ struct ice_mdd_vf_events {u16 last_printed; }; +struct ice_vf ; + +struct ice_vc_vf_ops { +int (*get_ver_msg)(struct ice_vf *vf,u8 *msg); +int (*get_vf_res_msg)(struct ice_vf *vf,u8 *msg); +void (*reset_vf)(struct ice_vf *vf); +int (*add_mac_addr_msg)(struct ice_vf *vf,u8 *msg); +int (*del_mac_addr_msg)(struct ice_vf *vf,u8 *msg); +int (*cfg_qs_msg)(struct ice_vf *vf,u8 *msg); +int (*ena_qs_msg)(struct ice_vf *vf,u8 *msg); +int (*dis_qs_msg)(struct ice_vf *vf,u8 *msg); +int (*request_qs_msg)(struct ice_vf *vf,u8 *msg); +int (*cfg_irq_map_msg)(struct ice_vf *vf,u8 *msg); +int (*config_rss_key)(struct ice_vf *vf,u8 *msg); +int (*config_rss_lut)(struct ice_vf *vf,u8 *msg); +int (*get_stats_msg)(struct ice_vf *vf,u8 *msg); +int (*cfg_promiscuous_mode_msg)(struct ice_vf *vf,u8 *msg); +int (*add_vlan_msg)(struct ice_vf *vf,u8 *msg); +int (*remove_vlan_msg)(struct ice_vf *vf,u8 *msg); +int (*ena_vlan_stripping)(struct ice_vf *vf); +int (*dis_vlan_stripping)(struct ice_vf *vf); +int (*handle_rss_cfg_msg)(struct ice_vf *vf,u8 *msg,bool add); +int (*add_fdir_fltr_msg)(struct ice_vf *vf,u8 *msg); +int (*del_fdir_fltr_msg)(struct ice_vf *vf,u8 *msg); +}; +/* VF information structure */ struct ice_vf {struct ice_pf *pf;
@@ -114,6 +140,8 @@ struct ice_vf {struct ice_repr *repr; +struct ice_vc_vf_ops vc_ops; +/* devlink port data */ struct devlink_port devlink_port; };
@@ -131,6 +159,8 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);void ice_vc_notify_link_state (struct ice_pf *pf);void ice_vc_notify_reset (struct ice_pf *pf);void ice_vc_notify_vf_link_state (struct ice_vf *vf); +void ice_vc_change_ops_to_repr (struct ice_vc_vf_ops *ops); +void ice_vc_set_dflt_vf_ops (struct ice_vc_vf_ops *ops);bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr);bool ice_reset_vf (struct ice_vf *vf,bool is_vflr);void ice_restore_all_vfs_msi_state (struct pci_dev *pdev);
@@ -172,6 +202,8 @@ 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_vc_notify_vf_link_state (struct ice_vf *vf) { } +static inline void ice_vc_change_ops_to_repr (struct ice_vc_vf_ops *ops) { } +static inline void ice_vc_set_dflt_vf_ops (struct ice_vc_vf_ops *ops) { }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) { }
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 4/12 ice: allow process vf opcodes in different ways
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 15 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 04/12] ice: allow process vf opcodes in different ways
In switchdev driver shouldn't add MAC, VLAN and promisc filters on iavf demand but should return success to not break normal iavf flow.
Achieve that by creating table of functions pointer with default functions used to parse iavf command. While parse iavf command, call correct function from table instead of calling function direct.
When port representors are being created change functions in table to new one that behaves correctly for switchdev puprose (ignoring new filters).
Change back to default ops when representors are being removed.
Quoted 9 lines
Co-developed-by Wojciech Drewek <[email protected]>Signed-off-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_repr.c | 23 ++- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 170 +++++++++++++++--- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 32 ++++ 3 files changed, 198 insertions(+), 27 deletions(-)
PATCH v3 5/12 ice: manage VSI antispoof and destination override
In reply to Michal SwiatkowskiImplement functions to make setting VSI security config easier. Main function ice_update_security fills security section field and checks against error in updating VSI. Rest functions are responsible for correct filling config according to user esceptations.
This helper is needed because destination override is located in this section. Driver has to set this bit to allow sttering Tx packet on VSI based on value in Tx descriptors.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 61 ++++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 11 +++++ 2 files changed, 72 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +61 -0
@@ -3571,3 +3571,64 @@ int ice_set_link(struct ice_vsi *vsi, bool ena)return 0 ; } + +/** +* ice_vsi_update_security - update security block in VSI +* @vsi: pointer to VSI structure +* @fill: function pointer to fill ctx +*/ +int ice_vsi_update_security (struct ice_vsi *vsi, +void (*fill)(struct ice_vsi_ctx *)) +{ +struct ice_vsi_ctx ctx = {0 }; + + ctx.info = vsi->info; + ctx.info.valid_sections =cpu_to_le16 (ICE_AQ_VSI_PROP_SECURITY_VALID ); +fill (&ctx); + +if (ice_update_vsi (&vsi->back->hw, vsi->idx, &ctx,NULL )) +return -ENODEV ; + + vsi->info = ctx.info; +return 0 ; +} + +/** +* ice_vsi_ctx_set_antispoof - set antispoof function in VSI ctx +* @ctx: pointer to VSI ctx structure +*/ +void ice_vsi_ctx_set_antispoof (struct ice_vsi_ctx *ctx) +{ + ctx->info.sec_flags |=ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF | + (ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << +ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S ); +} + +/** +* ice_vsi_ctx_clear_antispoof - clear antispoof function in VSI ctx +* @ctx: pointer to VSI ctx structure +*/ +void ice_vsi_ctx_clear_antispoof (struct ice_vsi_ctx *ctx) +{ + ctx->info.sec_flags &= ~ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF & + ~(ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << +ICE_AQ_VSI_SEC_TX_PRUNE_ENA_S ); +} + +/** +* ice_vsi_ctx_set_allow_override - allow destination override on VSI +* @ctx: pointer to VSI ctx structure +*/ +void ice_vsi_ctx_set_allow_override (struct ice_vsi_ctx *ctx) +{ + ctx->info.sec_flags |=ICE_AQ_VSI_SEC_FLAG_ALLOW_DEST_OVRD ; +} + +/** +* ice_vsi_ctx_clear_allow_override - turn off destination override on VSI +* @ctx: pointer to VSI ctx structure +*/ +void ice_vsi_ctx_clear_allow_override (struct ice_vsi_ctx *ctx) +{ + ctx->info.sec_flags &= ~ICE_AQ_VSI_SEC_FLAG_ALLOW_DEST_OVRD ; +}
drivers/net/ethernet/intel/ice/ice_lib.h +11 -0
@@ -116,4 +116,15 @@ bool ice_is_vsi_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi);int ice_set_dflt_vsi (struct ice_sw *sw,struct ice_vsi *vsi);int ice_clear_dflt_vsi (struct ice_sw *sw); + +int ice_vsi_update_security (struct ice_vsi *vsi, +void (*fill)(struct ice_vsi_ctx *)); + +void ice_vsi_ctx_set_antispoof (struct ice_vsi_ctx *ctx); + +void ice_vsi_ctx_clear_antispoof (struct ice_vsi_ctx *ctx); + +void ice_vsi_ctx_set_allow_override (struct ice_vsi_ctx *ctx); + +void ice_vsi_ctx_clear_allow_override (struct ice_vsi_ctx *ctx);#endif /* !_ICE_LIB_H_ */
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 5/12 ice: manage VSI antispoof and destination override
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 12 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 05/12] ice: manage VSI antispoof and destination override
Implement functions to make setting VSI security config easier.
Main functionice_update_securityfills security section field and checks against error in updating VSI. Rest functions are responsible for correct filling config according to user esceptations.This helper is needed because destination override is located in this section. Driver has to set this bit to allow sttering Tx packet on VSI based on value in Tx descriptors.
Quoted 6 lines
Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_lib.c| 61 ++++++++++++++++++++++++drivers/net/ethernet/intel/ice/ice_lib.h| 11 +++++2 files changed, 72 insertions(+)
PATCH v3 6/12 ice: allow changing lan_en and lb_en on dflt rules
In reply to Michal SwiatkowskiThere is no way to change default lan_en and lb_en flags while adding new rule. Add function that allows changing these flags on ICE_SW_LKUP_DFLT recipe and any rule id.
lan_en allows packet to go outside if rule is matched. Clearing this bit will block packet from sending it outside.
lb_en allows packet to be forwarded to other VSI. Clearing this bit will block packet from forwarding it to other VSI.
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 80 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fltr.h | 7 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.h | 6 ++ 4 files changed, 94 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_fltr.c +80 -0
@@ -451,3 +451,83 @@ enum ice_status ice_fltr_remove_eth(struct ice_vsi *vsi, u16 ethertype,return ice_fltr_prepare_eth (vsi, ethertype, flag, action, ice_fltr_remove_eth_list); } + +/** +* ice_fltr_update_rule_flags - update lan_en/lb_en flags +* @hw: pointer to hw +* @rule_id: id of rule being updated +* @recipe_id: recipe id of rule +* @act: current action field +* @type: Rx or Tx +* @src: source VSI +* @new_flags: combinations of lb_en and lan_en +*/ +static enum ice_status +ice_fltr_update_rule_flags (struct ice_hw *hw,u16 rule_id,u16 recipe_id, +u32 act,u16 type,u16 src,u32 new_flags) +{ +struct ice_aqc_sw_rules_elem *s_rule; +enum ice_status err; +u32 flags_mask; + + s_rule =kzalloc (ICE_SW_RULE_RX_TX_NO_HDR_SIZE ,GFP_KERNEL ); +if (!s_rule) +return ICE_ERR_NO_MEMORY ; + + flags_mask =ICE_SINGLE_ACT_LB_ENABLE |ICE_SINGLE_ACT_LAN_ENABLE ; + act &= ~flags_mask; + act |= (flags_mask & new_flags); + + s_rule->pdata.lkup_tx_rx.recipe_id =cpu_to_le16 (recipe_id); + s_rule->pdata.lkup_tx_rx.index =cpu_to_le16 (rule_id); + s_rule->pdata.lkup_tx_rx.act =cpu_to_le32 (act); + +if (type &ICE_FLTR_RX ) { + s_rule->pdata.lkup_tx_rx.src = +cpu_to_le16 (hw->port_info->lport); + s_rule->type =cpu_to_le16 (ICE_AQC_SW_RULES_T_LKUP_RX ); + + }else { + s_rule->pdata.lkup_tx_rx.src =cpu_to_le16 (src); + s_rule->type =cpu_to_le16 (ICE_AQC_SW_RULES_T_LKUP_TX ); + } + + err =ice_aq_sw_rules (hw, s_rule,ICE_SW_RULE_RX_TX_NO_HDR_SIZE ,1 , + ice_aqc_opc_update_sw_rules,NULL ); + +kfree (s_rule); +return err; +} + +/** +* ice_fltr_build_action - build action for rule +* @vsi_id: id of VSI which is use to build action +*/ +static u32 ice_fltr_build_action (u16 vsi_id) +{ +return ((vsi_id <<ICE_SINGLE_ACT_VSI_ID_S ) &ICE_SINGLE_ACT_VSI_ID_M ) | +ICE_SINGLE_ACT_VSI_FORWARDING |ICE_SINGLE_ACT_VALID_BIT ; +} + +/** +* ice_fltr_update_flags_dflt_rule - update flags on default rule +* @vsi: pointer to VSI +* @rule_id: id of rule +* @direction: Tx or Rx +* @new_flags: flags to update +* +* Function updates flags on default rule with ICE_SW_LKUP_DFLT. +* +* Flags should be a combination of ICE_SINGLE_ACT_LB_ENABLE and +* ICE_SINGLE_ACT_LAN_ENABLE. +*/ +enum ice_status +ice_fltr_update_flags_dflt_rule (struct ice_vsi *vsi,u16 rule_id,u8 direction, +u32 new_flags) +{ +u32 action =ice_fltr_build_action (vsi->vsi_num); +struct ice_hw *hw = &vsi->back->hw; + +return ice_fltr_update_rule_flags (hw, rule_id,ICE_SW_LKUP_DFLT , action, + direction, vsi->vsi_num, new_flags); +}
drivers/net/ethernet/intel/ice/ice_fltr.h +7 -0
@@ -46,4 +46,11 @@ enum ice_status ice_fltr_remove_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag, enum ice_sw_fwd_act_type action);void ice_fltr_remove_all (struct ice_vsi *vsi); + +enum ice_status +ice_fltr_update_flags (struct ice_vsi *vsi,u16 rule_id,u16 recipe_id, +u32 new_flags); +enum ice_status +ice_fltr_update_flags_dflt_rule (struct ice_vsi *vsi,u16 rule_id,u8 direction, +u32 new_flags);#endif
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -518,7 +518,7 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,* * Add(0x02a0)/Update(0x02a1)/Remove(0x02a2) switch rules commands to firmware */ -static enum ice_status +enum ice_status ice_aq_sw_rules (struct ice_hw *hw,void *rule_list,u16 rule_list_sz,u8 num_rules,enum ice_adminq_opc opc,struct ice_sq_cd *cd) {
drivers/net/ethernet/intel/ice/ice_switch.h +6 -0
@@ -14,6 +14,9 @@#define ICE_VSI_INVAL_ID 0xffff#define ICE_INVAL_Q_HANDLE 0xFFFF +#define ICE_SW_RULE_RX_TX_NO_HDR_SIZE \ + (offsetof(struct ice_aqc_sw_rules_elem, pdata.lkup_tx_rx.hdr)) +/* VSI context structure for add/get/update/free operations */ struct ice_vsi_ctx {u16 vsi_num;
@@ -251,4 +254,7 @@ u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);enum ice_status ice_replay_vsi_all_fltr (struct ice_hw *hw,u16 vsi_handle);void ice_rm_all_sw_replay_rule_info (struct ice_hw *hw); +enum ice_status +ice_aq_sw_rules (struct ice_hw *hw,void *rule_list,u16 rule_list_sz, +u8 num_rules,enum ice_adminq_opc opc,struct ice_sq_cd *cd);#endif /* _ICE_SWITCH_H_ */
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 6/12 ice: allow changing lan_en and lb_en on dflt rules
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 13 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 06/12] ice: allow changing
lan_enandlb_enon dflt rulesThere is no way to change default
lan_enandlb_enflags while adding new rule. Add function that allows changing these flags onICE_SW_LKUP_DFLTrecipe and any rule id.
lan_enallows packet to go outside if rule is matched. Clearing this bit will block packet from sending it outside.
lb_enallows packet to be forwarded to other VSI. Clearing this bit will block packet from forwarding it to other VSI.
Quoted 8 lines
Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_fltr.c | 80 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fltr.h | 7 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.h | 6 ++ 4 files changed, 94 insertions(+), 1 deletion(-)
PATCH v3 7/12 ice: set and release switchdev environment
In reply to Michal SwiatkowskiFrom: Grzegorz Nitka <[email protected]>
Switchdev environment has to be set up when user create VFs and eswitch mode is switchdev. Release is done when user delete all VFs.
Data path in this implementation is based on control plane VSI. This VSI is used to pass traffic from port representors to coresponfing VFs and vice versa. Default TX rule has to be added to forward packet to control plane VSI. This will redirect packets from VFs which don't match other rules to control plane VSI.
On RX site default rule is added on uplink VSI to receive all traffic that doesn't match other rules. When setting switchdev environment all other rules from VFs should be removed. Packet to VFs will be forwarded by control plane VSI.
As VF without any mac rules can't send any packet because of antispoof mechanism, VSI antispoof should be turned off on each VFs.
To send packet from representor to correct VSI, destintion VSI field in TX descriptor will have to be filled. Allow that by setting destination override bit in control plane VSI security config.
Packet from VFs will be received on control plane VSI. Driver should decide to which netdev forward the packet. Decision is made based on src_vsi field from descriptor. There is a target netdev list in control plane VSI struct which choose netdev based on src_vsi number.
--- drivers/net/ethernet/intel/ice/ice.h | 23 ++ drivers/net/ethernet/intel/ice/ice_eswitch.c | 394 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 16 +- drivers/net/ethernet/intel/ice/ice_main.c | 19 +- drivers/net/ethernet/intel/ice/ice_repr.c | 12 + drivers/net/ethernet/intel/ice/ice_repr.h | 2 + 6 files changed, 453 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +23 -0
@@ -342,6 +342,8 @@ struct ice_vsi {u16 num_xdp_txq;/* Used XDP queues */ u8 xdp_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */ +struct net_device **target_netdevs; +/* setup back reference, to which aggregator node this VSI * corresponds to */
@@ -401,6 +403,12 @@ enum ice_pf_flags {ICE_PF_FLAGS_NBITS /* must be last */ }; +struct ice_switchdev_info { +struct ice_vsi *control_vsi; +struct ice_vsi *uplink_vsi; +bool is_running; +}; +struct ice_agg_node {u32 agg_id;#define ICE_MAX_VSIS_IN_AGG_NODE 64
@@ -498,6 +506,8 @@ struct ice_pf {struct ice_link_default_override_tlv link_dflt_override;struct ice_lag *lag;/* Link Aggregation information */ +struct ice_switchdev_info switchdev; +#define ICE_INVALID_AGG_NODE_ID 0#define ICE_PF_AGG_NODE_ID_START 1#define ICE_MAX_PF_AGG_NODES 32
@@ -607,6 +617,18 @@ static inline struct ice_vsi *ice_get_ctrl_vsi(struct ice_pf *pf)return pf->vsi[pf->ctrl_vsi_idx]; } +/** +* ice_is_switchdev_running - check if switchdev is configured +* @pf: pointer to PF structure +* +* Returns true if eswitch mode is set to DEVLINK_ESWITCH_MODE_SWITCHDEV +* and switchdev is configured, false otherwise. +*/ +static inline bool ice_is_switchdev_running (struct ice_pf *pf) +{ +return pf->switchdev.is_running; +} +/** * ice_set_sriov_cap - enable SRIOV in PF flags * @pf: PF struct
@@ -635,6 +657,7 @@ bool netif_is_ice(struct net_device *dev);int ice_vsi_setup_tx_rings (struct ice_vsi *vsi);int ice_vsi_setup_rx_rings (struct ice_vsi *vsi);int ice_vsi_open_ctrl (struct ice_vsi *vsi); +int ice_vsi_open (struct ice_vsi *vsi);void ice_set_ethtool_ops (struct net_device *netdev);void ice_set_ethtool_safe_mode_ops (struct net_device *netdev);u16 ice_get_avail_txq_count (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_eswitch.c +394 -0
406 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_eswitch.h +12 -4
@@ -6,14 +6,23 @@#include <net/devlink.h> #ifdef CONFIG_ICE_SWITCHDEV +void ice_eswitch_release (struct ice_pf *pf); +int ice_eswitch_configure (struct ice_pf *pf); +int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode);int ice_eswitch_mode_set (struct devlink *devlink,u16 mode,struct netlink_ext_ack *extack);bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf);#else /* CONFIG_ICE_SWITCHDEV */ -static inline int -ice_eswitch_mode_get (struct devlink *devlink,u16 *mode) +static inline void ice_eswitch_release (struct ice_pf *pf) { } + +static inline int ice_eswitch_configure (struct ice_pf *pf) +{ +return -EOPNOTSUPP ; +} + +static inline int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode) {return DEVLINK_ESWITCH_MODE_LEGACY ; }
@@ -25,8 +34,7 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,return -EOPNOTSUPP ; } -static inline bool -ice_is_eswitch_mode_switchdev (struct ice_pf *pf) +static inline bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf) {return false; }
drivers/net/ethernet/intel/ice/ice_main.c +10 -9
@@ -46,7 +46,6 @@ static DEFINE_IDA(ice_aux_ida);static struct workqueue_struct *ice_wq;static const struct net_device_ops ice_netdev_safe_mode_ops;static const struct net_device_ops ice_netdev_ops; -static int ice_vsi_open (struct ice_vsi *vsi);static void ice_rebuild (struct ice_pf *pf,enum ice_reset_req reset_type);
@@ -6163,7 +6162,7 @@ int ice_vsi_open_ctrl(struct ice_vsi *vsi)* * Returns 0 on success, negative value on error */ -static int ice_vsi_open (struct ice_vsi *vsi) +int ice_vsi_open (struct ice_vsi *vsi) {char int_name[ICE_INT_NAME_STR_LEN ];struct ice_pf *pf = vsi->back;
@@ -6188,14 +6187,16 @@ static int ice_vsi_open(struct ice_vsi *vsi)if (err) goto err_setup_rx; -/* Notify the stack of the actual queue counts. */ - err =netif_set_real_num_tx_queues (vsi->netdev, vsi->num_txq); -if (err) - goto err_set_qs; +if (vsi->type ==ICE_VSI_PF ) { +/* Notify the stack of the actual queue counts. */ + err =netif_set_real_num_tx_queues (vsi->netdev, vsi->num_txq); +if (err) + goto err_set_qs; - err =netif_set_real_num_rx_queues (vsi->netdev, vsi->num_rxq); -if (err) - goto err_set_qs; + err =netif_set_real_num_rx_queues (vsi->netdev, vsi->num_rxq); +if (err) + goto err_set_qs; + } err =ice_up_complete (vsi);if (err)
drivers/net/ethernet/intel/ice/ice_repr.c +12 -0
@@ -265,3 +265,15 @@ void ice_repr_rem_from_all_vfs(struct ice_pf *pf)ice_vc_set_dflt_vf_ops (&vf->vc_ops); } } + +/** +* ice_repr_set_traffic_vsi - set traffic VSI for port representor +* @repr: repr on with VSI will be set +* @vsi: pointer to VSI that will be used by port representor to pass traffic +*/ +void ice_repr_set_traffic_vsi (struct ice_repr *repr,struct ice_vsi *vsi) +{ +struct ice_netdev_priv *np =netdev_priv (repr->netdev); + + np->vsi = vsi; +}
drivers/net/ethernet/intel/ice/ice_repr.h +2 -0
@@ -17,6 +17,8 @@ struct ice_repr {int ice_repr_add_for_all_vfs (struct ice_pf *pf);void ice_repr_rem_from_all_vfs (struct ice_pf *pf); +void ice_repr_set_traffic_vsi (struct ice_repr *repr,struct ice_vsi *vsi); +struct ice_repr *ice_netdev_to_repr (struct net_device *netdev);bool ice_is_port_repr_netdev (struct net_device *netdev);#endif
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 7/12 ice: set and release switchdev environment
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 33 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 07/12] ice: set and release switchdev environment
From: Grzegorz Nitka <[email protected]>
Switchdev environment has to be set up when user create VFs and eswitch mode is switchdev. Release is done when user delete all VFs.
Data path in this implementation is based on control plane VSI. This VSI is used to pass traffic from port representors to coresponfing VFs and vice versa. Default TX rule has to be added to forward packet to control plane VSI. This will redirect packets from VFs which don't match other rules to control plane VSI.
On RX site default rule is added on uplink VSI to receive all traffic that doesn't match other rules. When setting switchdev environment all other rules from VFs should be removed. Packet to VFs will be forwarded by control plane VSI.
As VF without any mac rules can't send any packet because of antispoof mechanism, VSI antispoof should be turned off on each VFs.
To send packet from representor to correct VSI, destintion VSI field in TX descriptor will have to be filled. Allow that by setting destination override bit in control plane VSI security config.
Packet from VFs will be received on control plane VSI. Driver should decide to which netdev forward the packet. Decision is made based on
src_vsifield from descriptor. There is a target netdev list in control plane VSI struct which choose netdev based onsrc_vsinumber.Co-developed-by Michal Swiatkowski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>Signed-off-by Grzegorz Nitka <[email protected]>
Quoted 9 lines
---
drivers/net/ethernet/intel/ice/ice.h | 23 ++ drivers/net/ethernet/intel/ice/ice_eswitch.c | 394 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 16 +- drivers/net/ethernet/intel/ice/ice_main.c | 19 +- drivers/net/ethernet/intel/ice/ice_repr.c | 12 + drivers/net/ethernet/intel/ice/ice_repr.h | 2 + 6 files changed, 453 insertions(+), 13 deletions(-)
PATCH v3 8/12 ice: introduce new type of VSI for switchdev
In reply to Michal SwiatkowskiFrom: Grzegorz Nitka <[email protected]>
New type of VSI has to be defined for switchdev control plane VSI. Number of allocated Tx and Rx queue has to be equeal to amount of VFs, because each port representor should have one Tx and Rx queue.
Also to not increase number of used irqs too much, control plane VSI uses only one q_vector and handle all queues in one irq. To allow handling all queues in one irq , new function to clean msix for eswitch was introduced. This function will shedule napi for each representor instead of sheduling it only for one like in normal clean irq function.
Only one additional msix has to be requested. Always try to request it in ice_ena_msix_range function.
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_base.c | 37 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 48 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_main.c | 7 +++ drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 93 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -85,6 +85,7 @@#define ICE_FDIR_MSIX 2#define ICE_RDMA_NUM_AEQ_MSIX 4#define ICE_MIN_RDMA_MSIX 2 +#define ICE_ESWITCH_MSIX 1#define ICE_NO_VSI 0xffff#define ICE_VSI_MAP_CONTIG 0#define ICE_VSI_MAP_SCATTER 1
drivers/net/ethernet/intel/ice/ice_base.c +36 -1
@@ -217,6 +217,31 @@ static u16 ice_calc_q_handle(struct ice_vsi *vsi, struct ice_ring *ring, u8 tc)return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset; } +/** +* ice_eswitch_calc_q_handle +* @ring: pointer to ring which unique index is needed +* +* To correctly work with many netdevs +* ring->q_index of Tx rings on switchdev VSI can repeat. Hardware ring setup +* requires unique q_index. Calculate it here by finding index in vsi->tx_rings +* of this ring. +* +* Return ICE_INVAL_Q_INDEX when index wasn't found. Should never happen, because VSI is get +* from ring->vsi, so it has to be present in this VSI. +*/ +static u16 ice_eswitch_calc_q_handle (struct ice_ring *ring) +{ +struct ice_vsi *vsi = ring->vsi; +int i; + +ice_for_each_txq (vsi, i) { +if (vsi->tx_rings[i] == ring) +return i; + } + +return ICE_INVAL_Q_INDEX ; +} +/** * ice_cfg_xps_tx_ring - Configure XPS for a Tx ring * @ring: The Tx ring to configure
@@ -280,6 +305,9 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q) tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf_id; tlan_ctx->vmvf_type =ICE_TLAN_CTX_VMVF_TYPE_VF ;break ; +case ICE_VSI_SWITCHDEV_CTRL : + tlan_ctx->vmvf_type =ICE_TLAN_CTX_VMVF_TYPE_VMQ ; +break ;default :return ; }
@@ -746,7 +774,14 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,/* Add unique software queue handle of the Tx queue per * TC into the VSI Tx ring */ - ring->q_handle =ice_calc_q_handle (vsi, ring, tc); +if (vsi->type ==ICE_VSI_SWITCHDEV_CTRL ) { + ring->q_handle =ice_eswitch_calc_q_handle (ring); + +if (ring->q_handle ==ICE_INVAL_Q_INDEX ) +return -ENODEV ; + }else { + ring->q_handle =ice_calc_q_handle (vsi, ring, tc); + } status =ice_ena_vsi_txq (vsi->port_info, vsi->idx, tc, ring->q_handle,1 , qg_buf, buf_len,NULL );
drivers/net/ethernet/intel/ice/ice_eswitch.c +1 -1
@@ -260,7 +260,7 @@ ice_eswitch_release_env(struct ice_pf *pf)static struct ice_vsi *ice_eswitch_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi) { -return NULL ; +return ice_vsi_setup (pf, pi,ICE_VSI_SWITCHDEV_CTRL ,ICE_INVAL_VFID ); }/**
drivers/net/ethernet/intel/ice/ice_lib.c +47 -1
114 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +7 -0
@@ -3544,6 +3544,13 @@ static int ice_ena_msix_range(struct ice_pf *pf) v_left -= needed; } +/* reserve for switchdev */ + needed =ICE_ESWITCH_MSIX ; +if (v_left < needed) + goto no_hw_vecs_left_err; + v_budget += needed; + v_left -= needed; +/* total used for non-traffic vectors */ v_other = v_budget;
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -139,6 +139,7 @@ enum ice_vsi_type {ICE_VSI_VF =1 ,ICE_VSI_CTRL =3 ,/* equates to ICE_VSI_PF with 1 queue pair */ ICE_VSI_LB =6 , + ICE_VSI_SWITCHDEV_CTRL = 7, }; struct ice_link_status {
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 8/12 ice: introduce new type of VSI for switchdev
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 19 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 08/12] ice: introduce new type of VSI for switchdev
From: Grzegorz Nitka <[email protected]>
New type of VSI has to be defined for switchdev control plane VSI. Number of allocated Tx and Rx queue has to be equeal to amount of VFs, because each port representor should have one Tx and Rx queue.
Also to not increase number of used irqs too much, control plane VSI uses only one
q_vectorand handle all queues in one irq.
To allow handling all queues in one irq , new function to clean msix for eswitch was introduced. This function will shedule napi for each representor instead of sheduling it only for one like in normal clean irq function.Only one additional msix has to be requested. Always try to request it in
ice_ena_msix_rangefunction.Signed-off-by Grzegorz Nitka <[email protected]>
Quoted 9 lines
---
drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_base.c | 37 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 48 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_main.c | 7 +++ drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 93 insertions(+), 3 deletions(-)
PATCH v3 9/12 ice: enable/disable switchdev when managing VFs
In reply to Michal SwiatkowskiFrom: Grzegorz Nitka <[email protected]>
Only way to enable switchdev is to create VFs when the eswitch mode is set to switchdev. Check if correct mode is set and enable switchdev in function which creating VFs.
Disable switchdev when user change number of VFs to 0. Changing eswitch mode back to legacy when VFs are created in switchdev mode isn't allowed.
As switchdev takes care of managing filter rules, adding new rules on VF is blocked.
In case of resetting VF driver has to update pointer in ice_repr struct, because after reset VSI related things can change.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 38 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 4 ++ drivers/net/ethernet/intel/ice/ice_main.c | 6 ++- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 +++++++++ 4 files changed, 64 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +38 -0
@@ -230,6 +230,32 @@ static void ice_eswitch_release_reprs(struct ice_pf *pf, } } +/** +* ice_eswitch_update_repr - reconfigure VF port representor +* @vsi: VF VSI for which port representor is configured +*/ +void ice_eswitch_update_repr (struct ice_vsi *vsi) +{ +struct ice_pf *pf = vsi->back; +struct ice_repr *repr; +struct ice_vf *vf; +int ret; + +if (!ice_is_switchdev_running (pf)) +return ; + + vf = &pf->vf[vsi->vf_id]; + repr = vf->repr; + repr->src_vsi = vsi; + repr->dst->u.port_info.port_id = vsi->vsi_num; + + ret =ice_vsi_update_security (vsi, ice_vsi_ctx_clear_antispoof); +if (ret) { +ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr.addr,ICE_FWD_TO_VSI ); +dev_err (ice_pf_to_dev (pf),"Failed to update VF %d port representor" , vsi->vf_id); + } +} +/** * ice_eswitch_release_env - clear switchdev HW filters * @pf: pointer to PF struct
@@ -423,6 +449,18 @@ int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode)return 0 ; } +/** +* ice_is_eswitch_mode_switchdev - check if eswitch mode is set to switchdev +* @pf: pointer to PF structure +* +* Returns true if eswitch mode is set to DEVLINK_ESWITCH_MODE_SWITCHDEV, +* false otherwise. +*/ +bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf) +{ +return pf->eswitch_mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV ; +} +/** * ice_eswitch_release - cleanup eswitch * @pf: pointer to PF structure
drivers/net/ethernet/intel/ice/ice_eswitch.h +4 -0
@@ -14,9 +14,13 @@ int ice_eswitch_mode_set(struct devlink *devlink, u16 mode, struct netlink_ext_ack *extack);bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf); + +void ice_eswitch_update_repr (struct ice_vsi *vsi);#else /* CONFIG_ICE_SWITCHDEV */ static inline void ice_eswitch_release (struct ice_pf *pf) { } +static inline void ice_eswitch_update_repr (struct ice_vsi *vsi) { } +static inline int ice_eswitch_configure (struct ice_pf *pf) {return -EOPNOTSUPP ;
drivers/net/ethernet/intel/ice/ice_main.c +4 -2
@@ -6065,7 +6065,8 @@ int ice_vsi_setup_tx_rings(struct ice_vsi *vsi)if (!ring)return -EINVAL ; - ring->netdev = vsi->netdev; +if (vsi->netdev) + ring->netdev = vsi->netdev; err =ice_setup_tx_ring (ring);if (err)break ;
@@ -6096,7 +6097,8 @@ int ice_vsi_setup_rx_rings(struct ice_vsi *vsi)if (!ring)return -EINVAL ; - ring->netdev = vsi->netdev; +if (vsi->netdev) + ring->netdev = vsi->netdev; err =ice_setup_rx_ring (ring);if (err)break ;
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +18 -0
@@ -6,6 +6,7 @@#include "ice_lib.h" #include "ice_fltr.h" #include "ice_flow.h" +#include "ice_eswitch.h" #include "ice_virtchnl_allowlist.h" #define FIELD_SELECTOR (proto_hdr_field) \
@@ -587,6 +588,8 @@ void ice_free_vfs(struct ice_pf *pf)if (!pf->vf)return ; +ice_eswitch_release (pf); +while (test_and_set_bit (ICE_VF_DIS , pf->state))usleep_range (1000 ,2000 );
@@ -899,6 +902,9 @@ static int ice_vf_rebuild_host_mac_cfg(struct ice_vf *vf)enum ice_status status;u8 broadcast[ETH_ALEN ]; +if (ice_is_eswitch_mode_switchdev (vf->pf)) +return 0 ; +eth_broadcast_addr (broadcast); status =ice_fltr_add_mac (vsi, broadcast,ICE_FWD_TO_VSI );if (status) {
@@ -1685,6 +1691,8 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) }ice_vf_post_vsi_rebuild (vf); + vsi =ice_get_vf_vsi (vf); +ice_eswitch_update_repr (vsi);/* if the VF has been reset allow it to come up again */ if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->malvfs,ICE_MAX_VF_COUNT , vf->vf_id))
@@ -1936,6 +1944,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs) }clear_bit (ICE_VF_DIS , pf->state); + +if (ice_eswitch_configure (pf)) + goto err_unroll_sriov; +return 0 ; err_unroll_sriov:
@@ -4781,6 +4793,12 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)struct ice_vf *vf;int ret; +if (ice_is_eswitch_mode_switchdev (pf)) { +dev_info (ice_pf_to_dev (pf), +"Trusted VF is forbidden in switchdev mode\n" ); +return -EOPNOTSUPP ; + } +if (ice_validate_vf_id (pf, vf_id))return -EINVAL ;
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 9/12 ice: enable/disable switchdev when managing VFs
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 21 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 09/12] ice: enable/disable switchdev when managing VFs
From: Grzegorz Nitka <[email protected]>
Only way to enable switchdev is to create VFs when the eswitch mode is set to switchdev. Check if correct mode is set and enable switchdev in function which creating VFs.
Disable switchdev when user change number of VFs to 0. Changing eswitch mode back to legacy when VFs are created in switchdev mode isn't allowed.
As switchdev takes care of managing filter rules, adding new rules on VF is blocked.
In case of resetting VF driver has to update pointer in
ice_reprstruct, because after reset VSI related things can change.Co-developed-by Wojciech Drewek <[email protected]>Signed-off-by Wojciech Drewek <[email protected]>Signed-off-by Grzegorz Nitka <[email protected]>
Quoted 7 lines
---
drivers/net/ethernet/intel/ice/ice_eswitch.c | 38 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 4 ++ drivers/net/ethernet/intel/ice/ice_main.c | 6 ++- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 18 +++++++++ 4 files changed, 64 insertions(+), 2 deletions(-)
PATCH v3 10/12 ice: rebuild switchdev when resetting all VFs
In reply to Michal SwiatkowskiFrom: Grzegorz Nitka <[email protected]>
As resetting all VFs behaves mostly like creating new VFs also eswitch infrastructure has to be recreated. The easiest way to do that is to rebuild eswitch after resetting VFs.
Implement helper functions to start and stop all representors queues. This is used to disable traffic on port representors.
In rebuild path:
- NAPI has to be disabled
- eswitch environment has to be set up
- new port representors have to be created, because the old one had pointer to not exsisting VFs
- new control plane VSI ring should be remaped
- NAPI hast to be enabled
- rxdid has to be set to FLEX_NIC_2, because this descriptor id support source_vsi, which is needed on control plane VSI queues
- port representors queues have to be started
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 83 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 10 +++ drivers/net/ethernet/intel/ice/ice_main.c | 11 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 20 +++++ drivers/net/ethernet/intel/ice/ice_repr.h | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 + 6 files changed, 130 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +83 -0
@@ -289,6 +289,18 @@ ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)return ice_vsi_setup (pf, pi,ICE_VSI_SWITCHDEV_CTRL ,ICE_INVAL_VFID ); } +/** +* ice_eswitch_napi_del - remove NAPI handle for all port representors +* @pf: pointer to PF structure +*/ +static void ice_eswitch_napi_del (struct ice_pf *pf) +{ +int i; + +ice_for_each_vf (pf, i) +netif_napi_del (&pf->vf[i].repr->q_vector->napi); +} +/** * ice_eswitch_napi_enable - enable NAPI for all port representors * @pf: pointer to PF structure
@@ -492,3 +504,74 @@ int ice_eswitch_configure(struct ice_pf *pf) pf->switchdev.is_running = true;return 0 ; } + +/** +* ice_eswitch_start_all_tx_queues - start Tx queues of all port representors +* @pf: pointer to PF structure +*/ +static void ice_eswitch_start_all_tx_queues (struct ice_pf *pf) +{ +struct ice_repr *repr; +int i; + +if (test_bit (ICE_DOWN , pf->state)) +return ; + +ice_for_each_vf (pf, i) { + repr = pf->vf[i].repr; +if (repr) +ice_repr_start_tx_queues (repr); + } +} + +/** +* ice_eswitch_stop_all_tx_queues - stop Tx queues of all port representors +* @pf: pointer to PF structure +*/ +void ice_eswitch_stop_all_tx_queues (struct ice_pf *pf) +{ +struct ice_repr *repr; +int i; + +if (test_bit (ICE_DOWN , pf->state)) +return ; + +ice_for_each_vf (pf, i) { + repr = pf->vf[i].repr; +if (repr) +ice_repr_stop_tx_queues (repr); + } +} + +/** +* ice_eswitch_rebuild - rebuild eswitch +* @pf: pointer to PF structure +*/ +int ice_eswitch_rebuild (struct ice_pf *pf) +{ +struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi; +int status; + +ice_eswitch_napi_disable (pf); +ice_eswitch_napi_del (pf); + + status =ice_eswitch_setup_env (pf); +if (status) +return status; + + status =ice_eswitch_setup_reprs (pf); +if (status) +return status; + +ice_eswitch_remap_rings_to_vectors (pf); + + status =ice_vsi_open (ctrl_vsi); +if (status) +return status; + +ice_eswitch_napi_enable (pf); +ice_eswitch_set_rxdid (ctrl_vsi,ICE_RXDID_FLEX_NIC_2 ); +ice_eswitch_start_all_tx_queues (pf); + +return 0 ; +}
drivers/net/ethernet/intel/ice/ice_eswitch.h +10 -0
@@ -8,6 +8,7 @@#ifdef CONFIG_ICE_SWITCHDEV void ice_eswitch_release (struct ice_pf *pf);int ice_eswitch_configure (struct ice_pf *pf); +int ice_eswitch_rebuild (struct ice_pf *pf);int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode);int
@@ -16,9 +17,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,bool ice_is_eswitch_mode_switchdev (struct ice_pf *pf);void ice_eswitch_update_repr (struct ice_vsi *vsi); + +void ice_eswitch_stop_all_tx_queues (struct ice_pf *pf);#else /* CONFIG_ICE_SWITCHDEV */ static inline void ice_eswitch_release (struct ice_pf *pf) { } +static inline void ice_eswitch_stop_all_tx_queues (struct ice_pf *pf) { } +static inline void ice_eswitch_update_repr (struct ice_vsi *vsi) { }static inline int ice_eswitch_configure (struct ice_pf *pf)
@@ -26,6 +31,11 @@ static inline int ice_eswitch_configure(struct ice_pf *pf)return -EOPNOTSUPP ; } +static inline int ice_eswitch_rebuild (struct ice_pf *pf) +{ +return -EOPNOTSUPP ; +} +static inline int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode) {return DEVLINK_ESWITCH_MODE_LEGACY ;
drivers/net/ethernet/intel/ice/ice_main.c +10 -1
@@ -19,6 +19,7 @@*/ #define CREATE_TRACE_POINTS #include "ice_trace.h" +#include "ice_eswitch.h" #define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"static const char ice_driver_string[] =DRV_SUMMARY ;
@@ -5996,9 +5997,11 @@ int ice_down(struct ice_vsi *vsi)/* Caller of this function is expected to set the * vsi->state ICE_DOWN bit */ -if (vsi->netdev) { +if (vsi->netdev && vsi->type ==ICE_VSI_PF ) {netif_carrier_off (vsi->netdev);netif_tx_disable (vsi->netdev); + }else if (vsi->type ==ICE_VSI_SWITCHDEV_CTRL ) { +ice_eswitch_stop_all_tx_queues (vsi->back); }ice_vsi_dis_irq (vsi);
@@ -6444,6 +6447,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err_vsi_rebuild; } + err =ice_vsi_rebuild_by_type (pf,ICE_VSI_SWITCHDEV_CTRL ); +if (err) { +dev_err (dev,"Switchdev CTRL VSI rebuild failed: %d\n" , err); + goto err_vsi_rebuild; + } +/* If Flow Director is active */ if (test_bit (ICE_FLAG_FD_ENA , pf->flags)) { err =ice_vsi_rebuild_by_type (pf,ICE_VSI_CTRL );
drivers/net/ethernet/intel/ice/ice_repr.c +20 -0
@@ -266,6 +266,26 @@ void ice_repr_rem_from_all_vfs(struct ice_pf *pf) } } +/** +* ice_repr_start_tx_queues - start Tx queues of port representor +* @repr: pointer to repr structure +*/ +void ice_repr_start_tx_queues (struct ice_repr *repr) +{ +netif_carrier_on (repr->netdev); +netif_tx_start_all_queues (repr->netdev); +} + +/** +* ice_repr_stop_tx_queues - stop Tx queues of port representor +* @repr: pointer to repr structure +*/ +void ice_repr_stop_tx_queues (struct ice_repr *repr) +{ +netif_carrier_off (repr->netdev); +netif_tx_stop_all_queues (repr->netdev); +} +/** * ice_repr_set_traffic_vsi - set traffic VSI for port representor * @repr: repr on with VSI will be set
drivers/net/ethernet/intel/ice/ice_repr.h +3 -0
@@ -17,6 +17,9 @@ struct ice_repr {int ice_repr_add_for_all_vfs (struct ice_pf *pf);void ice_repr_rem_from_all_vfs (struct ice_pf *pf); +void ice_repr_start_tx_queues (struct ice_repr *repr); +void ice_repr_stop_tx_queues (struct ice_repr *repr); +void ice_repr_set_traffic_vsi (struct ice_repr *repr,struct ice_vsi *vsi);struct ice_repr *ice_netdev_to_repr (struct net_device *netdev);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +4 -0
@@ -1560,6 +1560,10 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)ice_vf_post_vsi_rebuild (vf); } +if (ice_is_eswitch_mode_switchdev (pf)) +if (ice_eswitch_rebuild (pf)) +dev_warn (dev,"eswitch rebuild failed\n" ); +ice_flush (hw);clear_bit (ICE_VF_DIS , pf->state);
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 10/12 ice: rebuild switchdev when resetting all VFs
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 24 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 10/12] ice: rebuild switchdev when resetting all VFs
From: Grzegorz Nitka <[email protected]>
As resetting all VFs behaves mostly like creating new VFs also eswitch infrastructure has to be recreated. The easiest way to do that is to rebuild eswitch after resetting VFs.
Implement helper functions to start and stop all representors queues. This is used to disable traffic on port representors.
In rebuild path:
- NAPI has to be disabled
- eswitch environment has to be set up
- new port representors have to be created, because the old one had pointer to not exsisting VFs
- new control plane VSI ring should be remaped
- NAPI hast to be enabled
- rxdid has to be set toFLEX_NIC_2, because this descriptor id supportsource_vsi, which is needed on control plane VSI queues
- port representors queues have to be startedSigned-off-by Grzegorz Nitka <[email protected]>
Quoted 9 lines
---
drivers/net/ethernet/intel/ice/ice_eswitch.c | 83 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 10 +++ drivers/net/ethernet/intel/ice/ice_main.c | 11 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 20 +++++ drivers/net/ethernet/intel/ice/ice_repr.h | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 + 6 files changed, 130 insertions(+), 1 deletion(-)
PATCH v3 11/12 ice: switchdev slow path
In reply to Michal SwiatkowskiFrom: Grzegorz Nitka <[email protected]>
Slow path means allowing packet to go from uplink to representor and from representor to correct VF on Rx site and from VF to representor and to uplink on Tx site.
To acomplish this driver, has to set correct Tx descriptor. When packet is sent from representor to VF, destination should be set to VF VSI. When packet is sent from uplink port destination should be uplink to bypass switch infrastructure and send packet outside.
On Rx site driver should check source VSI field from Rx descriptor and based on that forward packed to correct netdev. To allow this there is a target netdevs table in control plane VSI struct.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 79 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 26 ++++++ .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 43 ++++++++++ drivers/net/ethernet/intel/ice/ice_repr.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 3 + drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 4 +- 6 files changed, 155 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +79 -0
@@ -256,6 +256,57 @@ void ice_eswitch_update_repr(struct ice_vsi *vsi) } } +/** +* ice_eswitch_port_start_xmit - callback for packets transmit +* @skb: send buffer +* @netdev: network interface device structure +* +* Returns NETDEV_TX_OK if sent, else an error code +*/ +netdev_tx_t +ice_eswitch_port_start_xmit (struct sk_buff *skb,struct net_device *netdev) +{ +struct ice_netdev_priv *np; +struct ice_repr *repr; +struct ice_vsi *vsi; + + np =netdev_priv (netdev); + vsi = np->vsi; + +if (ice_is_reset_in_progress (vsi->back->state)) +return NETDEV_TX_BUSY ; + + repr =ice_netdev_to_repr (netdev); +skb_dst_drop (skb); +dst_hold ((struct dst_entry *)repr->dst); +skb_dst_set (skb, (struct dst_entry *)repr->dst); + skb->queue_mapping = repr->vf->vf_id; + +return ice_start_xmit (skb, netdev); +} + +/** +* ice_eswitch_set_target_vsi - set switchdev context in Tx context descriptor +* @skb: pointer to send buffer +* @off: pointer to offload struct +*/ +void ice_eswitch_set_target_vsi (struct sk_buff *skb, +struct ice_tx_offload_params *off) +{ +struct metadata_dst *dst =skb_metadata_dst (skb); +u64 cd_cmd, dst_vsi; + +if (!dst) { + cd_cmd =ICE_TX_CTX_DESC_SWTCH_UPLINK <<ICE_TXD_CTX_QW1_CMD_S ; + off->cd_qw1 |= (cd_cmd |ICE_TX_DESC_DTYPE_CTX ); + }else { + cd_cmd =ICE_TX_CTX_DESC_SWTCH_VSI <<ICE_TXD_CTX_QW1_CMD_S ; + dst_vsi = ((u64 )dst->u.port_info.port_id << +ICE_TXD_CTX_QW1_VSI_S ) &ICE_TXD_CTX_QW1_VSI_M ; + off->cd_qw1 = cd_cmd | dst_vsi |ICE_TX_DESC_DTYPE_CTX ; + } +} +/** * ice_eswitch_release_env - clear switchdev HW filters * @pf: pointer to PF struct
@@ -448,6 +499,34 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,return 0 ; } +/** +* ice_eswitch_get_target_netdev - return port representor netdev +* @rx_ring: pointer to rx ring +* @rx_desc: pointer to rx descriptor +* +* When working in switchdev mode context (when control VSI is used), this +* function returns netdev of appropriate port representor. For non-switchdev +* context, regular netdev associated with rx ring is returned. +*/ +struct net_device * +ice_eswitch_get_target_netdev (struct ice_ring *rx_ring, +union ice_32b_rx_flex_desc *rx_desc) +{ +struct ice_32b_rx_flex_desc_nic_2 *desc; +struct ice_vsi *vsi = rx_ring->vsi; +struct ice_vsi *control_vsi; +u16 target_vsi_id; + + control_vsi = vsi->back->switchdev.control_vsi; +if (vsi != control_vsi) +return rx_ring->netdev; + + desc = (struct ice_32b_rx_flex_desc_nic_2 *)rx_desc; + target_vsi_id =le16_to_cpu (desc->src_vsi); + +return vsi->target_netdevs[target_vsi_id]; +} +/** * ice_eswitch_mode_get - get current eswitch mode * @devlink: pointer to devlink structure
drivers/net/ethernet/intel/ice/ice_eswitch.h +26 -0
@@ -19,11 +19,24 @@ bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf);void ice_eswitch_update_repr (struct ice_vsi *vsi);void ice_eswitch_stop_all_tx_queues (struct ice_pf *pf); + +struct net_device * +ice_eswitch_get_target_netdev (struct ice_ring *rx_ring, +union ice_32b_rx_flex_desc *rx_desc); + +void ice_eswitch_set_target_vsi (struct sk_buff *skb, +struct ice_tx_offload_params *off); +netdev_tx_t +ice_eswitch_port_start_xmit (struct sk_buff *skb,struct net_device *netdev);#else /* CONFIG_ICE_SWITCHDEV */ static inline void ice_eswitch_release (struct ice_pf *pf) { }static inline void ice_eswitch_stop_all_tx_queues (struct ice_pf *pf) { } +static inline void +ice_eswitch_set_target_vsi (struct sk_buff *skb, +struct ice_tx_offload_params *off) { } +static inline void ice_eswitch_update_repr (struct ice_vsi *vsi) { }static inline int ice_eswitch_configure (struct ice_pf *pf)
@@ -52,5 +65,18 @@ static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf) {return false; } + +static inline struct net_device * +ice_eswitch_get_target_netdev (struct ice_ring *rx_ring, +union ice_32b_rx_flex_desc *rx_desc) +{ +return rx_ring->netdev; +} + +static inline netdev_tx_t +ice_eswitch_port_start_xmit (struct sk_buff *skb,struct net_device *netdev) +{ +return NETDEV_TX_BUSY ; +}#endif /* CONFIG_ICE_SWITCHDEV */ #endif
drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h +43 -0
55 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_repr.c +1 -0
@@ -114,6 +114,7 @@ static const struct net_device_ops ice_repr_netdev_ops = { .ndo_get_phys_port_name = ice_repr_get_phys_port_name, .ndo_open = ice_repr_open, .ndo_stop = ice_repr_stop, + .ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_get_devlink_port = ice_repr_get_devlink_port, };
drivers/net/ethernet/intel/ice/ice_txrx.c +3 -0
@@ -13,6 +13,7 @@#include "ice_trace.h" #include "ice_dcb_lib.h" #include "ice_xsk.h" +#include "ice_eswitch.h" #define ICE_RX_HDR_SIZE 256
@@ -2249,6 +2250,8 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring) ICE_TXD_CTX_QW1_CMD_S);ice_tstamp (tx_ring, skb, first, &offload); +if (ice_is_switchdev_running (vsi->back)) +ice_eswitch_set_target_vsi (skb, &offload);if (offload.cd_qw1 &ICE_TX_DESC_DTYPE_CTX ) {struct ice_tx_ctx_desc *cdesc;
drivers/net/ethernet/intel/ice/ice_txrx_lib.c +3 -1
@@ -2,6 +2,7 @@/* Copyright (c) 2019, Intel Corporation. */ #include "ice_txrx_lib.h" +#include "ice_eswitch.h" /** * ice_release_rx_desc - Store the new tail and head values
@@ -185,7 +186,8 @@ ice_process_skb_fields(struct ice_ring *rx_ring,ice_rx_hash (rx_ring, rx_desc, skb, ptype);/* modifies the skb - consumes the enet header */ - skb->protocol =eth_type_trans (skb, rx_ring->netdev); + skb->protocol =eth_type_trans (skb,ice_eswitch_get_target_netdev + (rx_ring, rx_desc));ice_rx_csum (rx_ring, skb, rx_desc, ptype);
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 11/12 ice: switchdev slow path
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 20 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 11/12] ice: switchdev slow path
From: Grzegorz Nitka <[email protected]>
Slow path means allowing packet to go from uplink to representor and from representor to correct VF on Rx site and from VF to representor and to uplink on Tx site.
To acomplish this driver, has to set correct Tx descriptor. When packet is sent from representor to VF, destination should be set to VF VSI. When packet is sent from uplink port destination should be uplink to bypass switch infrastructure and send packet outside.
On Rx site driver should check source VSI field from Rx descriptor and based on that forward packed to correct netdev. To allow this there is a target netdevs table in control plane VSI struct.
Co-developed-by Michal Swiatkowski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>Signed-off-by Grzegorz Nitka <[email protected]>
Quoted 9 lines
---
drivers/net/ethernet/intel/ice/ice_eswitch.c | 79 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 26 ++++++ .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 43 ++++++++++ drivers/net/ethernet/intel/ice/ice_repr.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 3 + drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 4 +- 6 files changed, 155 insertions(+), 1 deletion(-)
PATCH v3 12/12 ice: add port representor ethtool ops and stats
In reply to Michal SwiatkowskiFrom: Wojciech Drewek <[email protected]>
Introduce the following ethtool operations for VF's representor:
-get_drvinfo
-get_strings
-get_ethtool_stats
-get_sset_count
-get_link
In all cases, exsisting operations were used with minor changes which allow us to detect if ethtool op was called for representor. Only VF VSI stats will be available for representor.
Implement ndo_get_stats64 for port representor. This will update VF VSI stats and read them.
--- drivers/net/ethernet/intel/ice/ice.h | 14 +++++++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 32 ++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_repr.c | 29 ++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +14 -0
@@ -605,6 +605,19 @@ static inline struct ice_vsi *ice_get_main_vsi(struct ice_pf *pf)return NULL ; } +/** +* ice_get_netdev_priv_vsi - return VSI associated with netdev priv. +* @np: private netdev structure +*/ +static inline struct ice_vsi *ice_get_netdev_priv_vsi (struct ice_netdev_priv *np) +{ +/* In case of port representor return source port VSI. */ +if (np->repr) +return np->repr->src_vsi; +else +return np->vsi; +} +/** * ice_get_ctrl_vsi - Get the control VSI * @pf: PF instance
@@ -660,6 +673,7 @@ int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);int ice_vsi_open_ctrl (struct ice_vsi *vsi);int ice_vsi_open (struct ice_vsi *vsi);void ice_set_ethtool_ops (struct net_device *netdev); +void ice_set_ethtool_repr_ops (struct net_device *netdev);void ice_set_ethtool_safe_mode_ops (struct net_device *netdev);u16 ice_get_avail_txq_count (struct ice_pf *pf);u16 ice_get_avail_rxq_count (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_ethtool.c +29 -3
@@ -173,7 +173,7 @@ static void ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct ice_netdev_priv *np = netdev_priv(netdev); -struct ice_vsi *vsi = np->vsi; +struct ice_vsi *vsi =ice_get_netdev_priv_vsi (np);struct ice_pf *pf = vsi->back;struct ice_hw *hw = &pf->hw;struct ice_orom_info *orom;
@@ -869,7 +869,7 @@ ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test,static void ice_get_strings (struct net_device *netdev,u32 stringset,u8 *data) {struct ice_netdev_priv *np =netdev_priv (netdev); -struct ice_vsi *vsi = np->vsi; +struct ice_vsi *vsi =ice_get_netdev_priv_vsi (np);unsigned int i;u8 *p = data;
@@ -879,6 +879,9 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)ethtool_sprintf (&p, ice_gstrings_vsi_stats[i].stat_string); +if (ice_is_port_repr_netdev (netdev)) +return ; +ice_for_each_alloc_txq (vsi, i) {ethtool_sprintf (&p,"tx_queue_%u_packets" , i);ethtool_sprintf (&p,"tx_queue_%u_bytes" , i);
@@ -1301,6 +1304,9 @@ static int ice_get_sset_count(struct net_device *netdev, int sset)* order of strings will suffer from race conditions and are * not safe. */ +if (ice_is_port_repr_netdev (netdev)) +return ICE_VSI_STATS_LEN ; +return ICE_ALL_STATS_LEN (netdev);case ETH_SS_TEST :return ICE_TEST_LEN ;
@@ -1316,7 +1322,7 @@ ice_get_ethtool_stats(struct net_device *netdev, struct ethtool_stats __always_unused *stats, u64 *data) { struct ice_netdev_priv *np = netdev_priv(netdev); -struct ice_vsi *vsi = np->vsi; +struct ice_vsi *vsi =ice_get_netdev_priv_vsi (np);struct ice_pf *pf = vsi->back;struct ice_ring *ring;unsigned int j;
@@ -1332,6 +1338,9 @@ ice_get_ethtool_stats(struct net_device *netdev, sizeof(u64)) ? *(u64 *)p : *(u32 *)p; } +if (ice_is_port_repr_netdev (netdev)) +return ; +/* populate per queue stats */ rcu_read_lock ();
@@ -4051,6 +4060,23 @@ void ice_set_ethtool_safe_mode_ops(struct net_device *netdev) netdev->ethtool_ops = &ice_ethtool_safe_mode_ops; } +static const struct ethtool_ops ice_ethtool_repr_ops = { + .get_drvinfo = ice_get_drvinfo, + .get_link = ethtool_op_get_link, + .get_strings = ice_get_strings, + .get_ethtool_stats = ice_get_ethtool_stats, + .get_sset_count = ice_get_sset_count, +}; + +/** +* ice_set_ethtool_repr_ops - setup VF's port representor ethtool ops +* @netdev: network interface device structure +*/ +void ice_set_ethtool_repr_ops (struct net_device *netdev) +{ + netdev->ethtool_ops = &ice_ethtool_repr_ops; +} +/** * ice_set_ethtool_ops - setup netdev ethtool ops * @netdev: network interface device structure
drivers/net/ethernet/intel/ice/ice_repr.c +29 -0
@@ -39,6 +39,33 @@ ice_repr_get_phys_port_name(struct net_device *netdev, char *buf, size_t len)return 0 ; } +/** +* ice_repr_get_stats64 - get VF stats for VFPR use +* @netdev: pointer to port representor netdev +* @stats: pointer to struct where stats can be stored +*/ +static void +ice_repr_get_stats64 (struct net_device *netdev,struct rtnl_link_stats64 *stats) +{ +struct ice_netdev_priv *np =netdev_priv (netdev); +struct ice_vsi *vsi = np->repr->src_vsi; +struct ice_eth_stats *eth_stats; + +ice_update_vsi_stats (vsi); + eth_stats = &vsi->eth_stats; + + stats->tx_packets = eth_stats->tx_unicast + eth_stats->tx_broadcast + + eth_stats->tx_multicast; + stats->rx_packets = eth_stats->rx_unicast + eth_stats->rx_broadcast + + eth_stats->rx_multicast; + stats->tx_bytes = eth_stats->tx_bytes; + stats->rx_bytes = eth_stats->rx_bytes; + stats->multicast = eth_stats->rx_multicast; + stats->tx_errors = eth_stats->tx_errors; + stats->tx_dropped = eth_stats->tx_discards; + stats->rx_dropped = eth_stats->rx_discards; +} +/** * ice_netdev_to_repr - Get port representor for given netdevice * @netdev: pointer to port representor netdev
@@ -112,6 +139,7 @@ ice_repr_get_devlink_port(struct net_device *netdev)static const struct net_device_ops ice_repr_netdev_ops = { .ndo_get_phys_port_name = ice_repr_get_phys_port_name, + .ndo_get_stats64 = ice_repr_get_stats64, .ndo_open = ice_repr_open, .ndo_stop = ice_repr_stop, .ndo_start_xmit = ice_eswitch_port_start_xmit,
@@ -136,6 +164,7 @@ ice_repr_reg_netdev(struct net_device *netdev) {eth_hw_addr_random (netdev); netdev->netdev_ops = &ice_repr_netdev_ops; +ice_set_ethtool_repr_ops (netdev);netif_carrier_off (netdev);netif_tx_stop_all_queues (netdev);
Signature · 1 line
2.30.2
Penigalapati
PATCH v3 12/12 ice: add port representor ethtool ops and stats
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, June 25, 2021 8:15 AM
Quoted 19 lines
Subject: [Intel-wired-lan] [PATCH net-next v3 12/12] ice: add port representor ethtool ops and stats
From: Wojciech Drewek <[email protected]>
Introduce the following ethtool operations for VF's representor:
-get_drvinfo
-get_strings
-get_ethtool_stats
-get_sset_count
-get_linkIn all cases, exsisting operations were used with minor changes which allow us to detect if ethtool op was called for representor. Only VF VSI stats will be available for representor.
Implement
ndo_get_stats64for port representor. This will update VF VSI stats and read them.
Quoted 7 lines
Signed-off-by Wojciech Drewek <[email protected]>---
drivers/net/ethernet/intel/ice/ice.h | 14 +++++++++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 32 ++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_repr.c | 29 ++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-)