ice: support devlink subfunction
Subsystems (3)
cover ice: support devlink subfunction
Hi,
Currently ice driver does not allow creating more than one networking device per physical function. The only way to have more hardware backed netdev is to use SR-IOV.
Following patchset adds support for devlink port API. For each new pcisf type port, driver allocates new VSI, configures all resources needed, including dynamically MSIX vectors, program rules and registers new netdev.
This series supports only one Tx/Rx queue pair per subfunction.
Example commands:
devlink port add pci/0000:31:00.1 flavour pcisf pfnum 1 sfnum 1000 devlink port function set pci/0000:31:00.1/1 hw_addr 00:00:00:00:03:14 devlink port function set pci/0000:31:00.1/1 state active devlink port function del pci/0000:31:00.1/1
Make the port representor and eswitch code generic to support subfunction representor type.
VSI configuration is slightly different between VF and SF. It needs to be reflected in the code.
Most recent previous patchset (not containing port representor for SF support). [1]
[1] https://lore.kernel.org/netdev/[email protected]/
Michal Swiatkowski (7):
ice: treat subfunction VSI the same as PF VSI
ice: create port representor for SF
ice: don't set target VSI for subfunction
ice: check if SF is ready in ethtool ops
ice: netdevice ops for SF representor
ice: support subfunction devlink Tx topology
ice: basic support for VLAN in subfunctions
Piotr Raczynski (7):
ice: add new VSI type for subfunctions
ice: export ice ndo_ops functions
ice: add basic devlink subfunctions support
ice: allocate devlink for subfunction
ice: base subfunction aux driver
ice: implement netdev for subfunction
ice: allow to activate and deactivate subfunction
drivers/net/ethernet/intel/ice/Makefile | 2 + .../net/ethernet/intel/ice/devlink/devlink.c | 48 ++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 516 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 43 ++ drivers/net/ethernet/intel/ice/ice.h | 19 +- drivers/net/ethernet/intel/ice/ice_base.c | 5 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 ++- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +- drivers/net/ethernet/intel/ice/ice_lib.c | 52 +- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 66 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 22 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 329 +++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 33 ++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 26 files changed, 1362 insertions(+), 138 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.c create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.h create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h
Signature · 1 line
2.42.0
PATCH 1/14 ice: add new VSI type for subfunctions
From: Piotr Raczynski <[email protected]>
Add required plumbing for new VSI type dedicated to devlink subfunctions. Make sure that the vsi is properly configured and destroyed. Also allow loading XDP and AF_XDP sockets.
The first implementation of devlink subfunctions supports only one Tx/Rx queue pair per given subfunction.
--- drivers/net/ethernet/intel/ice/ice_base.c | 5 +++- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_lib.c | 25 ++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_main.c | 7 ++++-- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 6 files changed, 35 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +4 -1
@@ -330,6 +330,9 @@ ice_setup_tx_ctx(struct ice_tx_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf->vf_id; tlan_ctx->vmvf_type =ICE_TLAN_CTX_VMVF_TYPE_VF ;break ; +case ICE_VSI_SF : + tlan_ctx->vmvf_type =ICE_TLAN_CTX_VMVF_TYPE_VMQ ; +break ;default :return ; }
@@ -526,7 +529,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) ring->rx_buf_len = ring->vsi->rx_buf_len; -if (ring->vsi->type ==ICE_VSI_PF ) { +if (ring->vsi->type ==ICE_VSI_PF || ring->vsi->type ==ICE_VSI_SF ) {if (!xdp_rxq_info_is_reg (&ring->xdp_rxq)) { err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, ring->q_index,
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1 -0
@@ -187,6 +187,7 @@ void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi) vsi->tc_cfg.numtc =ice_dcb_get_num_tc (cfg);break ;case ICE_VSI_CHNL : +case ICE_VSI_SF : vsi->tc_cfg.ena_tc =BIT (ice_get_first_droptc (vsi)); vsi->tc_cfg.numtc =1 ;break ;
drivers/net/ethernet/intel/ice/ice_lib.c +23 -2
@@ -20,6 +20,8 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type)return "ICE_VSI_PF" ;case ICE_VSI_VF :return "ICE_VSI_VF" ; +case ICE_VSI_SF : +return "ICE_VSI_SF" ;case ICE_VSI_CTRL :return "ICE_VSI_CTRL" ;case ICE_VSI_CHNL :
@@ -141,6 +143,7 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi) {switch (vsi->type) {case ICE_VSI_PF : +case ICE_VSI_SF :case ICE_VSI_CTRL :case ICE_VSI_LB :/* a user could change the values of num_[tr]x_desc using
@@ -207,6 +210,12 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)max_t (int, vsi->alloc_rxq, vsi->alloc_txq));break ; +case ICE_VSI_SF : + vsi->alloc_txq =1 ; + vsi->alloc_rxq =1 ; + vsi->num_q_vectors =1 ; + vsi->irq_dyn_alloc = true; +break ;case ICE_VSI_VF :if (vf->num_req_qs) vf->num_vf_qs = vf->num_req_qs;
@@ -566,6 +575,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)switch (vsi->type) {case ICE_VSI_PF : +case ICE_VSI_SF :/* Setup default MSIX irq handler for VSI */ vsi->irq_handler = ice_msix_clean_rings;break ;
@@ -894,6 +904,11 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi) max_rss_size); vsi->rss_lut_type =ICE_LUT_PF ;break ; +case ICE_VSI_SF : + vsi->rss_table_size =ICE_LUT_VSI_SIZE ; + vsi->rss_size =min_t (u16,num_online_cpus (), max_rss_size); + vsi->rss_lut_type =ICE_LUT_VSI ; +break ;case ICE_VSI_VF :/* VF VSI will get a small RSS table. * For VSI_LUT, LUT size should be set to 64 bytes.
@@ -1141,6 +1156,7 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi) lut_type =ICE_AQ_VSI_Q_OPT_RSS_LUT_PF ;break ;case ICE_VSI_VF : +case ICE_VSI_SF :/* VF VSI will gets a small RSS table which is a VSI LUT type */ lut_type =ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI ;break ;
@@ -1219,6 +1235,7 @@ static int ice_vsi_init(struct ice_vsi *vsi, u32 vsi_flags)case ICE_VSI_PF : ctxt->flags =ICE_AQ_VSI_TYPE_PF ;break ; +case ICE_VSI_SF :case ICE_VSI_CHNL : ctxt->flags =ICE_AQ_VSI_TYPE_VMDQ2 ;break ;
@@ -2100,6 +2117,7 @@ static void ice_set_agg_vsi(struct ice_vsi *vsi)case ICE_VSI_CHNL :case ICE_VSI_LB :case ICE_VSI_PF : +case ICE_VSI_SF : max_agg_nodes =ICE_MAX_PF_AGG_NODES ; agg_node_id_start =ICE_PF_AGG_NODE_ID_START ; agg_node_iter = &pf->pf_agg_node[0 ];
@@ -2269,6 +2287,7 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)switch (vsi->type) {case ICE_VSI_CTRL : +case ICE_VSI_SF :case ICE_VSI_PF : ret =ice_vsi_alloc_q_vectors (vsi);if (ret)
@@ -2654,7 +2673,8 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked)clear_bit (ICE_VSI_NEEDS_RESTART , vsi->state); -if (vsi->netdev && vsi->type ==ICE_VSI_PF ) { +if (vsi->netdev && (vsi->type ==ICE_VSI_PF || + vsi->type ==ICE_VSI_SF )) {if (netif_running (vsi->netdev)) {if (!locked)rtnl_lock ();
@@ -2683,7 +2703,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked)set_bit (ICE_VSI_NEEDS_RESTART , vsi->state); -if (vsi->type ==ICE_VSI_PF && vsi->netdev) { +if (vsi->netdev && (vsi->type ==ICE_VSI_PF || + vsi->type ==ICE_VSI_SF )) {if (netif_running (vsi->netdev)) {if (!locked)rtnl_lock ();
drivers/net/ethernet/intel/ice/ice_main.c +5 -2
@@ -2947,6 +2947,9 @@ int ice_vsi_determine_xdp_res(struct ice_vsi *vsi)if (avail < cpus /2 )return -ENOMEM ; +if (vsi->type ==ICE_VSI_SF ) + avail = vsi->alloc_txq; + vsi->num_xdp_txq =min_t (u16, avail, cpus);if (vsi->num_xdp_txq < cpus)
@@ -3062,8 +3065,8 @@ static int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp)struct ice_netdev_priv *np =netdev_priv (dev);struct ice_vsi *vsi = np->vsi; -if (vsi->type !=ICE_VSI_PF ) { -NL_SET_ERR_MSG_MOD (xdp->extack,"XDP can be loaded only on PF VSI" ); +if (vsi->type !=ICE_VSI_PF && vsi->type !=ICE_VSI_SF ) { +NL_SET_ERR_MSG_MOD (xdp->extack,"XDP can be loaded only on PF or SF VSI" );return -EINVAL ; }
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -150,6 +150,7 @@ enum ice_vsi_type {ICE_VSI_CTRL =3 ,/* equates to ICE_VSI_PF with 1 queue pair */ ICE_VSI_CHNL =4 ,ICE_VSI_LB =6 , + ICE_VSI_SF = 9, }; struct ice_link_status {
drivers/net/ethernet/intel/ice/ice_xsk.c +1 -1
@@ -288,7 +288,7 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) {int err; -if (vsi->type !=ICE_VSI_PF ) +if (vsi->type !=ICE_VSI_PF && vsi->type !=ICE_VSI_SF )return -EINVAL ; if (qid >= vsi->netdev->real_num_rx_queues ||
Signature · 1 line
2.42.0
PATCH 2/14 ice: export ice ndo_ops functions
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Make some of the netdevice_ops functions visible from outside for another VSI type created netdev.
--- drivers/net/ethernet/intel/ice/ice.h | 8 +++++ drivers/net/ethernet/intel/ice/ice_lib.c | 22 ++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 37 ++++------------------- 4 files changed, 37 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +8 -0
@@ -984,6 +984,14 @@ void ice_unload(struct ice_pf *pf);void ice_adv_lnk_speed_maps_init (void );int ice_init_dev (struct ice_pf *pf);void ice_deinit_dev (struct ice_pf *pf); +int ice_change_mtu (struct net_device *netdev,int new_mtu); +void ice_tx_timeout (struct net_device *netdev,unsigned int txqueue); +int ice_xdp (struct net_device *dev,struct netdev_bpf *xdp); +void ice_set_netdev_features (struct net_device *netdev); +int ice_vlan_rx_add_vid (struct net_device *netdev,__be16 proto,u16 vid); +int ice_vlan_rx_kill_vid (struct net_device *netdev,__be16 proto,u16 vid); +void ice_get_stats64 (struct net_device *netdev, +struct rtnl_link_stats64 *stats);/** * ice_set_rdma_cap - enable RDMA support
drivers/net/ethernet/intel/ice/ice_lib.c +22 -0
@@ -2838,6 +2838,28 @@ void ice_vsi_set_napi_queues(struct ice_vsi *vsi)ice_q_vector_set_napi_queues (vsi->q_vectors[i]); } +/** +* ice_napi_add - register NAPI handler for the VSI +* @vsi: VSI for which NAPI handler is to be registered +* +* This function is only called in the driver's load path. Registering the NAPI +* handler is done in ice_vsi_alloc_q_vector() for all other cases (i.e. resume, +* reset/rebuild, etc.) +*/ +void ice_napi_add (struct ice_vsi *vsi) +{ +int v_idx; + +if (!vsi->netdev) +return ; + +ice_for_each_q_vector (vsi, v_idx) { +netif_napi_add (vsi->netdev, &vsi->q_vectors[v_idx]->napi, + ice_napi_poll); +__ice_q_vector_set_napi_queues (vsi->q_vectors[v_idx], false); + } +} +/** * ice_vsi_release - Delete a VSI and free its resources * @vsi: the VSI being removed
drivers/net/ethernet/intel/ice/ice_lib.h +1 -0
@@ -53,6 +53,7 @@ void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked);void ice_q_vector_set_napi_queues (struct ice_q_vector *q_vector);void ice_vsi_set_napi_queues (struct ice_vsi *vsi); +void ice_napi_add (struct ice_vsi *vsi);int ice_vsi_release (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_main.c +6 -31
@@ -3060,7 +3060,7 @@ static int ice_xdp_safe_mode(struct net_device __always_unused *dev,* @dev: netdevice * @xdp: XDP command */ -static int ice_xdp (struct net_device *dev,struct netdev_bpf *xdp) +int ice_xdp (struct net_device *dev,struct netdev_bpf *xdp) {struct ice_netdev_priv *np =netdev_priv (dev);struct ice_vsi *vsi = np->vsi;
@@ -3519,28 +3519,6 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)return 0 ; } -/** -* ice_napi_add - register NAPI handler for the VSI -* @vsi: VSI for which NAPI handler is to be registered -* -* This function is only called in the driver's load path. Registering the NAPI -* handler is done in ice_vsi_alloc_q_vector() for all other cases (i.e. resume, -* reset/rebuild, etc.) -*/ -static void ice_napi_add (struct ice_vsi *vsi) -{ -int v_idx; - -if (!vsi->netdev) -return ; - -ice_for_each_q_vector (vsi, v_idx) { -netif_napi_add (vsi->netdev, &vsi->q_vectors[v_idx]->napi, - ice_napi_poll); -__ice_q_vector_set_napi_queues (vsi->q_vectors[v_idx], false); - } -} -/** * ice_set_ops - set netdev and ethtools ops for the given netdev * @vsi: the VSI associated with the new netdev
@@ -3574,7 +3552,7 @@ static void ice_set_ops(struct ice_vsi *vsi)* ice_set_netdev_features - set features for the given netdev * @netdev: netdev instance */ -static void ice_set_netdev_features (struct net_device *netdev) +void ice_set_netdev_features (struct net_device *netdev) {struct ice_pf *pf =ice_netdev_to_pf (netdev);bool is_dvm_ena =ice_is_dvm_ena (&pf->hw);
@@ -3756,8 +3734,7 @@ ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)* * net_device_ops implementation for adding VLAN IDs */ -static int -ice_vlan_rx_add_vid (struct net_device *netdev,__be16 proto,u16 vid) +int ice_vlan_rx_add_vid (struct net_device *netdev,__be16 proto,u16 vid) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi_vlan_ops *vlan_ops;
@@ -3819,8 +3796,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)* * net_device_ops implementation for removing VLAN IDs */ -static int -ice_vlan_rx_kill_vid (struct net_device *netdev,__be16 proto,u16 vid) +int ice_vlan_rx_kill_vid (struct net_device *netdev,__be16 proto,u16 vid) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi_vlan_ops *vlan_ops;
@@ -7059,7 +7035,6 @@ void ice_update_pf_stats(struct ice_pf *pf)* @netdev: network interface device structure * @stats: main device statistics structure */ -static void ice_get_stats64 (struct net_device *netdev,struct rtnl_link_stats64 *stats) {struct ice_netdev_priv *np =netdev_priv (netdev);
@@ -7732,7 +7707,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)* * Returns 0 on success, negative on failure */ -static int ice_change_mtu (struct net_device *netdev,int new_mtu) +int ice_change_mtu (struct net_device *netdev,int new_mtu) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi;
@@ -8156,7 +8131,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,* @netdev: network interface device structure * @txqueue: Tx queue */ -static void ice_tx_timeout (struct net_device *netdev,unsigned int txqueue) +void ice_tx_timeout (struct net_device *netdev,unsigned int txqueue) {struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_tx_ring *tx_ring =NULL ;
Signature · 1 line
2.42.0
PATCH 3/14 ice: add basic devlink subfunctions support
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev.
For now, subfunction is limited to only one Tx/Rx queue pair.
Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX interrupt vectors using new API calls with pci_msix_alloc_irq_at and pci_msix_free_irq.
Support both automatic and manual subfunction numbers. If no subfunction number is provided, use xa_alloc to pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of the dyn_ports xarray.
--- .../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +3 -0
@@ -6,6 +6,7 @@#include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h"
@@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, }; static int
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +357 -0
366 lines not on this page · raw message
drivers/net/ethernet/intel/ice/devlink/devlink_port.h +33 -0
@@ -4,9 +4,42 @@#ifndef _DEVLINK_PORT_H_#define _DEVLINK_PORT_H_ +#include "../ice.h" + +/** +* struct ice_dynamic_port - Track dynamically added devlink port instance +* @hw_addr: the HW address for this port +* @active: true if the port has been activated +* @devlink_port: the associated devlink port structure +* @pf: pointer to the PF private structure +* @vsi: the VSI associated with this port +* +* An instance of a dynamically added devlink port. Each port flavour +*/ +struct ice_dynamic_port { +u8 hw_addr[ETH_ALEN ]; +u8 active:1 ; +struct devlink_port devlink_port; +struct ice_pf *pf; +struct ice_vsi *vsi; +u32 sfnum; +}; + +void ice_dealloc_all_dynamic_ports (struct ice_pf *pf); +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); +int ice_devlink_create_sf_port (struct ice_dynamic_port *dyn_port); +void ice_devlink_destroy_sf_port (struct ice_dynamic_port *dyn_port); + +#define ice_devlink_port_to_dyn (p) \ + container_of(port, struct ice_dynamic_port, devlink_port) +int +ice_devlink_port_new (struct devlink *devlink, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack, +struct devlink_port **devlink_port);#endif /* _DEVLINK_PORT_H_ */
drivers/net/ethernet/intel/ice/ice.h +4 -0
@@ -651,6 +651,9 @@ struct ice_pf {struct ice_eswitch eswitch;struct ice_esw_br_port *br_port; +struct xarray dyn_ports; +struct xarray sf_nums; +#define ICE_INVALID_AGG_NODE_ID 0#define ICE_PF_AGG_NODE_ID_START 1#define ICE_MAX_PF_AGG_NODES 32
@@ -907,6 +910,7 @@ 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); +void ice_set_ethtool_sf_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);int ice_vsi_recfg_qs (struct ice_vsi *vsi,int new_rx,int new_tx,bool locked);
drivers/net/ethernet/intel/ice/ice_lib.c +3 -2
@@ -7,6 +7,7 @@#include "ice_lib.h" #include "ice_fltr.h" #include "ice_dcb_lib.h" +#include "ice_type.h" #include "ice_vsi_vlan_ops.h" /**
@@ -440,7 +441,7 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi)* This deallocates the VSI's queue resources, removes it from the PF's * VSI array if necessary, and deallocates the VSI */ -static void ice_vsi_free (struct ice_vsi *vsi) +void ice_vsi_free (struct ice_vsi *vsi) {struct ice_pf *pf =NULL ;struct device *dev;
@@ -612,7 +613,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)* * returns a pointer to a VSI on success, NULL on failure. */ -static struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf) +struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf);struct ice_vsi *vsi =NULL ;
drivers/net/ethernet/intel/ice/ice_lib.h +2 -0
@@ -66,6 +66,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked);int ice_vsi_rebuild (struct ice_vsi *vsi,u32 vsi_flags);int ice_vsi_cfg (struct ice_vsi *vsi); +struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf); +void ice_vsi_free (struct ice_vsi *vsi);bool ice_is_reset_in_progress (unsigned long *state);int ice_wait_for_reset (struct ice_pf *pf,unsigned long timeout);
drivers/net/ethernet/intel/ice/ice_main.c +8 -1
@@ -3965,6 +3965,9 @@ static void ice_deinit_pf(struct ice_pf *pf)if (pf->ptp.clock)ptp_clock_unregister (pf->ptp.clock); + +xa_destroy (&pf->dyn_ports); +xa_destroy (&pf->sf_nums); }/**
@@ -4058,6 +4061,9 @@ static int ice_init_pf(struct ice_pf *pf)hash_init (pf->vfs.table);ice_mbx_init_snapshot (&pf->hw); +xa_init (&pf->dyn_ports); +xa_init (&pf->sf_nums); +return 0 ; }
@@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev)ice_remove_arfs (pf);devl_lock (priv_to_devlink (pf)); +ice_dealloc_all_dynamic_ports (pf);ice_deinit_devlink (pf);ice_unload (pf);
@@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi)if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev && vsi->type ==ICE_VSI_PF ) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) {ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);
Signature · 1 line
2.42.0
Re: [iwl-next v1 03/14] ice: add basic devlink subfunctions support
Quoted 8 lines · Tue, May 07, 2024 at 01:45:04PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev.
Quoted 5 lines
For now, subfunction is limited to only one Tx/Rx queue pair.
Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX
Interesting. You talk about actitation, yet you don't implement it here.
Quoted 182 lines
interrupt vectors using new API calls with
pci_msix_alloc_irq_atandpci_msix_free_irq.Support both automatic and manual subfunction numbers. If no subfunction number is provided, use
xa_allocto pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of thedyn_portsxarray.Reviewed-by Wojciech Drewek <[email protected]>Co-developed-by Jacob Keller <[email protected]>Signed-off-by Jacob Keller <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ice/devlink/devlink.c +3
-0@@ -6,6 +6,7 @@#include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" @@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, };static int
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +120
-0@@ -5,6 +5,9 @@#include "ice.h" #include "devlink.h" +#include "devlink_port.h" +#include "ice_lib.h" +#include "ice_fltr.h" static int ice_active_port_option =-1 ;@@ -428,3 +431,357 @@ void ice_devlink_destroy_vf_port(struct ice_vf *vf)devl_rate_leaf_destroy (&vf->devlink_port);devl_port_unregister (&vf->devlink_port); } + +/** +* ice_dealloc_dynamic_port - Deallocate and remove a dynamic port +* @dyn_port: dynamic port instance to deallocate +* +* Free resources associated with a dynamically added devlink port. Will +* deactivate the port if its currently active. +*/ +static void ice_dealloc_dynamic_port (struct ice_dynamic_port *dyn_port) +{ +struct devlink_port *devlink_port = &dyn_port->devlink_port; +struct ice_pf *pf = dyn_port->pf; + +xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf); +devl_port_unregister (devlink_port); +ice_vsi_free (dyn_port->vsi); +xa_erase (&pf->dyn_ports, dyn_port->vsi->idx); +kfree (dyn_port); +} + +/** +* ice_dealloc_all_dynamic_ports - Deallocate all dynamic devlink ports +* @pf: pointer to the pf structure +*/ +void ice_dealloc_all_dynamic_ports (struct ice_pf *pf) +{ +struct ice_dynamic_port *dyn_port; +unsigned long index; + +xa_for_each (&pf->dyn_ports, index, dyn_port) +ice_dealloc_dynamic_port (dyn_port); +} + +/** +* ice_devlink_port_new_check_attr - Check that new port attributes are valid +* @pf: pointer to the PF structure +* @new_attr: the attributes for the new port +* @extack: extack for reporting error messages +* +* Check that the attributes for the new port are valid before continuing to +* allocate the devlink port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_new_check_attr (struct ice_pf *pf, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack) +{ +if (new_attr->flavour !=DEVLINK_PORT_FLAVOUR_PCI_SF ) { +NL_SET_ERR_MSG_MOD (extack,"Flavour other than pcisf is not supported" ); +return -EOPNOTSUPP ; + } + +if (new_attr->controller_valid) { +NL_SET_ERR_MSG_MOD (extack,"Setting controller is not supported" ); +return -EOPNOTSUPP ; + } + +if (new_attr->port_index_valid) { +NL_SET_ERR_MSG_MOD (extack,"Port index is invalid" ); +return -EOPNOTSUPP ; + } + +if (new_attr->pfnum != pf->hw.bus.func) { +NL_SET_ERR_MSG_MOD (extack,"Incorrect pfnum supplied" ); +return -EINVAL ; + } + +if (!pci_msix_can_alloc_dyn (pf->pdev)) { +NL_SET_ERR_MSG_MOD (extack,"Dynamic MSIX-X interrupt allocation is not supported" ); +return -EOPNOTSUPP ; + } + +return 0 ; +} + +/** +* ice_devlink_port_del - devlink handler for port delete +* @devlink: pointer to devlink +* @port: devlink port to be deleted +* @extack: pointer to extack +* +* Deletes devlink port and deallocates all resources associated with +* created subfunction. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_del (struct devlink *devlink,struct devlink_port *port, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); +ice_dealloc_dynamic_port (dyn_port); + +return 0 ; +} + +/** +* ice_devlink_port_fn_hw_addr_set - devlink handler for mac address set +* @port: pointer to devlink port +* @hw_addr: hw address to set +* @hw_addr_len: hw address length +* @extack: extack for reporting error messages +* +* Sets mac address for the port, verifies arguments and copies address +* to the subfunction structure. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_hw_addr_set (struct devlink_port *port,const u8 *hw_addr, +int hw_addr_len, +struct netlink_ext_ack *extack) +{
drivers/net/ethernet/intel/ice/devlink/devlink_port.c void ice_devlink_destroy_vf_port(struct ice_vf *vf) · line 560
Quoted 10 lines
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +10
-0+struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (hw_addr_len !=ETH_ALEN || !is_valid_ether_addr (hw_addr)) { +NL_SET_ERR_MSG_MOD (extack,"Invalid ethernet address" ); +return -EADDRNOTAVAIL ; + } + +ether_addr_copy (dyn_port->hw_addr, hw_addr);
How does this work? You copy the address to the internal structure, but where you update the HW?
Quoted 372 lines
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +227
-0+ +return 0 ; +} + +/** +* ice_devlink_port_fn_hw_addr_get - devlink handler for mac address get +* @port: pointer to devlink port +* @hw_addr: hw address to set +* @hw_addr_len: hw address length +* @extack: extack for reporting error messages +* +* Returns mac address for the port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_hw_addr_get (struct devlink_port *port,u8 *hw_addr, +int *hw_addr_len, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +ether_addr_copy (hw_addr, dyn_port->hw_addr); + *hw_addr_len =ETH_ALEN ; + +return 0 ; +} + +static const struct devlink_port_ops ice_devlink_port_sf_ops = { + .port_del = ice_devlink_port_del, + .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, + .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, +}; + +/** +* ice_reserve_sf_num - Reserve a subfunction number for this port +* @pf: pointer to the pf structure +* @new_attr: devlink port attributes requested +* @extack: extack for reporting error messages +* @sfnum: on success, the sf number reserved +* +* Reserve a subfunction number for this port. Only called for +* DEVLINK_PORT_FLAVOUR_PCI_SF ports. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_reserve_sf_num (struct ice_pf *pf, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack,u32 *sfnum) +{ +int err; + +/* If user didn't request an explicit number, pick one */ +if (!new_attr->sfnum_valid) +return xa_alloc (&pf->sf_nums, sfnum,NULL , xa_limit_32b, +GFP_KERNEL ); + +/* Otherwise, check and use the number provided */ + err =xa_insert (&pf->sf_nums, new_attr->sfnum,NULL ,GFP_KERNEL ); +if (err) { +if (err == -EBUSY ) +NL_SET_ERR_MSG_MOD (extack,"Subfunction with given sfnum already exists" ); +return err; + } + + *sfnum = new_attr->sfnum; + +return 0 ; +} + +/** +* ice_devlink_create_sf_port - Register PCI subfunction devlink port +* @dyn_port: the dynamic port instance structure for this subfunction +* +* Register PCI subfunction flavour devlink port for a dynamically added +* subfunction port. +* +* Return: zero on success or an error code on failure. +*/ +int ice_devlink_create_sf_port (struct ice_dynamic_port *dyn_port) +{ +struct devlink_port_attrs attrs = {}; +struct devlink_port *devlink_port; +struct devlink *devlink; +struct ice_vsi *vsi; +struct device *dev; +struct ice_pf *pf; +int err; + + vsi = dyn_port->vsi; + pf = dyn_port->pf; + dev =ice_pf_to_dev (pf); + + devlink_port = &dyn_port->devlink_port; + + attrs.flavour =DEVLINK_PORT_FLAVOUR_PCI_SF ; + attrs.pci_sf.pf = pf->hw.bus.func; + attrs.pci_sf.sf = dyn_port->sfnum; + +devlink_port_attrs_set (devlink_port, &attrs); + devlink =priv_to_devlink (pf); + + err =devl_port_register_with_ops (devlink, devlink_port, vsi->idx, + &ice_devlink_port_sf_ops); +if (err) { +dev_err (dev,"Failed to create devlink port for Subfunction %d" , + vsi->idx); +return err; + } + +return 0 ; +} + +/** +* ice_devlink_destroy_sf_port - Destroy the devlink_port for this SF +* @dyn_port: the dynamic port instance structure for this subfunction +* +* Unregisters the devlink_port structure associated with this SF. +*/ +void ice_devlink_destroy_sf_port (struct ice_dynamic_port *dyn_port) +{ +devl_port_unregister (&dyn_port->devlink_port); +} + +/** +* ice_alloc_dynamic_port - Allocate new dynamic port +* @pf: pointer to the pf structure +* @new_attr: devlink port attributes requested +* @extack: extack for reporting error messages +* @devlink_port: index of newly created devlink port +* +* Allocate a new dynamic port instance and prepare it for configuration +* with devlink. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_alloc_dynamic_port (struct ice_pf *pf, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack, +struct devlink_port **devlink_port) +{ +struct ice_dynamic_port *dyn_port; +struct ice_vsi *vsi; +u32 sfnum; +int err; + + err =ice_reserve_sf_num (pf, new_attr, extack, &sfnum); +if (err) +return err; + + dyn_port =kzalloc (sizeof (*dyn_port),GFP_KERNEL ); +if (!dyn_port) { + err = -ENOMEM ; + goto unroll_reserve_sf_num; + } + + vsi =ice_vsi_alloc (pf); +if (!vsi) { +NL_SET_ERR_MSG_MOD (extack,"Unable to allocate VSI" ); + err = -ENOMEM ; + goto unroll_dyn_port_alloc; + } + + dyn_port->vsi = vsi; + dyn_port->pf = pf; + dyn_port->sfnum = sfnum; +eth_random_addr (dyn_port->hw_addr); + + err =xa_insert (&pf->dyn_ports, vsi->idx, dyn_port,GFP_KERNEL ); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Port index reservation failed" ); + goto unroll_vsi_alloc; + } + + err =ice_devlink_create_sf_port (dyn_port); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Port registration failed" ); + goto unroll_xa_insert; + } + + *devlink_port = &dyn_port->devlink_port; + +return 0 ; + +unroll_xa_insert: +xa_erase (&pf->dyn_ports, vsi->idx); +unroll_vsi_alloc: +ice_vsi_free (vsi); +unroll_dyn_port_alloc: +kfree (dyn_port); +unroll_reserve_sf_num: +xa_erase (&pf->sf_nums, sfnum); + +return err; +} + +/** +* ice_devlink_port_new - devlink handler for the new port +* @devlink: pointer to devlink +* @new_attr: pointer to the port new attributes +* @extack: extack for reporting error messages +* @devlink_port: pointer to a new port +* +* Creates new devlink port, checks new port attributes and reject +* any unsupported parameters, allocates new subfunction for that port. +* +* Return: zero on success or an error code on failure. +*/ +int +ice_devlink_port_new (struct devlink *devlink, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack, +struct devlink_port **devlink_port) +{ +struct ice_pf *pf =devlink_priv (devlink); +int err; + + err =ice_devlink_port_new_check_attr (pf, new_attr, extack); +if (err) +return err; + +return ice_alloc_dynamic_port (pf, new_attr, extack, devlink_port); +}drivers/net/ethernet/intel/ice/devlink/devlink_port.h +33
-0@@ -4,9 +4,42 @@#ifndef _DEVLINK_PORT_H_#define _DEVLINK_PORT_H_ +#include "../ice.h" + +/** +* struct ice_dynamic_port - Track dynamically added devlink port instance +* @hw_addr: the HW address for this port +* @active: true if the port has been activated +* @devlink_port: the associated devlink port structure +* @pf: pointer to the PF private structure +* @vsi: the VSI associated with this port +* +* An instance of a dynamically added devlink port. Each port flavour +*/ +struct ice_dynamic_port { +u8 hw_addr[ETH_ALEN ]; +u8 active:1 ; +struct devlink_port devlink_port; +struct ice_pf *pf; +struct ice_vsi *vsi; +u32 sfnum; +}; + +void ice_dealloc_all_dynamic_ports (struct ice_pf *pf); +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); +int ice_devlink_create_sf_port (struct ice_dynamic_port *dyn_port); +void ice_devlink_destroy_sf_port (struct ice_dynamic_port *dyn_port); + +#define ice_devlink_port_to_dyn (p) \ + container_of(port, struct ice_dynamic_port, devlink_port) +int +ice_devlink_port_new (struct devlink *devlink, +const struct devlink_port_new_attrs *new_attr, +struct netlink_ext_ack *extack, +struct devlink_port **devlink_port);#endif /* _DEVLINK_PORT_H_ */ drivers/net/ethernet/intel/ice/ice.h +4
-0@@ -651,6 +651,9 @@ struct ice_pf {struct ice_eswitch eswitch;struct ice_esw_br_port *br_port; +struct xarray dyn_ports; +struct xarray sf_nums; +#define ICE_INVALID_AGG_NODE_ID 0#define ICE_PF_AGG_NODE_ID_START 1#define ICE_MAX_PF_AGG_NODES 32@@ -907,6 +910,7 @@ 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); +void ice_set_ethtool_sf_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);int ice_vsi_recfg_qs (struct ice_vsi *vsi,int new_rx,int new_tx,bool locked);drivers/net/ethernet/intel/ice/ice_lib.c +3
-2@@ -7,6 +7,7 @@#include "ice_lib.h" #include "ice_fltr.h" #include "ice_dcb_lib.h" +#include "ice_type.h" #include "ice_vsi_vlan_ops.h" /** @@ -440,7 +441,7 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi)* This deallocates the VSI's queue resources, removes it from the PF's * VSI array if necessary, and deallocates the VSI */ -static void ice_vsi_free (struct ice_vsi *vsi) +void ice_vsi_free (struct ice_vsi *vsi) {struct ice_pf *pf =NULL ;struct device *dev;@@ -612,7 +613,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)* * returns a pointer to a VSI on success, NULL on failure. */ -static struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf) +struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf);struct ice_vsi *vsi =NULL ;drivers/net/ethernet/intel/ice/ice_lib.h +2
-0@@ -66,6 +66,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked);int ice_vsi_rebuild (struct ice_vsi *vsi,u32 vsi_flags);int ice_vsi_cfg (struct ice_vsi *vsi); +struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf); +void ice_vsi_free (struct ice_vsi *vsi);bool ice_is_reset_in_progress (unsigned long *state);int ice_wait_for_reset (struct ice_pf *pf,unsigned long timeout);drivers/net/ethernet/intel/ice/ice_main.c +7
-0@@ -3965,6 +3965,9 @@ static void ice_deinit_pf(struct ice_pf *pf)if (pf->ptp.clock)ptp_clock_unregister (pf->ptp.clock); + +xa_destroy (&pf->dyn_ports); +xa_destroy (&pf->sf_nums); }/** @@ -4058,6 +4061,9 @@ static int ice_init_pf(struct ice_pf *pf)hash_init (pf->vfs.table);ice_mbx_init_snapshot (&pf->hw); +xa_init (&pf->dyn_ports); +xa_init (&pf->sf_nums); +return 0 ; }@@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev)ice_remove_arfs (pf);devl_lock (priv_to_devlink (pf)); +ice_dealloc_all_dynamic_ports (pf);ice_deinit_devlink (pf);ice_unload (pf);
drivers/net/ethernet/intel/ice/ice_main.c static int ice_up_complete(struct ice_vsi *vsi) · line 6687
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-1@@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi)if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev && vsi->type ==ICE_VSI_PF ) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) {
I think this is some leftover, remove.
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-0ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);Signature · 1 line
2.42.0
Re: [iwl-next v1 03/14] ice: add basic devlink subfunctions support
Quoted 9 lines · Jiri Pirko
Quoted 8 lines · Tue, May 07, 2024 at 01:45:04PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev.
Quoted 8 lines
Quoted 5 lines
For now, subfunction is limited to only one Tx/Rx queue pair.
Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX
Interesting. You talk about actitation, yet you don't implement it here.
I will rephrase it. I meant that new VSI needs to be created even before any activation or configuration.
Quoted 49 lines
Quoted 49 lines
interrupt vectors using new API calls with
pci_msix_alloc_irq_atandpci_msix_free_irq.Support both automatic and manual subfunction numbers. If no subfunction number is provided, use
xa_allocto pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of thedyn_portsxarray.Reviewed-by Wojciech Drewek <[email protected]>Co-developed-by Jacob Keller <[email protected]>Signed-off-by Jacob Keller <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ice/devlink/devlink.c +4
-0@@ -6,6 +6,7 @@#include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" @@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, }; +
[...]
Quoted 22 lines
Quoted 22 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +22
-0+/** +* ice_devlink_port_fn_hw_addr_set - devlink handler for mac address set +* @port: pointer to devlink port +* @hw_addr: hw address to set +* @hw_addr_len: hw address length +* @extack: extack for reporting error messages +* +* Sets mac address for the port, verifies arguments and copies address +* to the subfunction structure. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_hw_addr_set (struct devlink_port *port,const u8 *hw_addr, +int hw_addr_len, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (hw_addr_len !=ETH_ALEN || !is_valid_ether_addr (hw_addr)) {
Quoted 9 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c
Quoted 5 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +5
-0+NL_SET_ERR_MSG_MOD (extack,"Invalid ethernet address" ); +return -EADDRNOTAVAIL ; + } + +ether_addr_copy (dyn_port->hw_addr, hw_addr);How does this work? You copy the address to the internal structure, but where you update the HW?
When the basic MAC filter is added in HW.
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +3
-0+ +return 0 ; +}
[...]
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-0@@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev)ice_remove_arfs (pf);devl_lock (priv_to_devlink (pf)); +ice_dealloc_all_dynamic_ports (pf);ice_deinit_devlink (pf);ice_unload (pf);@@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi)
Quoted 7 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c static int ice_up_complete(struct ice_vsi *vsi) · line 6687
Quoted 4 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-1if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev && vsi->type ==ICE_VSI_PF ) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) {I think this is some leftover, remove.
Yeah, thanks, will remove it.
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +0
-0ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);Signature · 1 line
2.42.0
Re: [iwl-next v1 03/14] ice: add basic devlink subfunctions support
Quoted 106 lines · Fri, May 10, 2024 at 09:13:51AM CEST, [email protected] wrote:
Quoted 9 lines · Jiri Pirko
Quoted 8 lines · Tue, May 07, 2024 at 01:45:04PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev.
Quoted 8 lines
Quoted 5 lines
For now, subfunction is limited to only one Tx/Rx queue pair.
Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX
Interesting. You talk about actitation, yet you don't implement it here.
I will rephrase it. I meant that new VSI needs to be created even before any activation or configuration.
Quoted 49 lines
Quoted 49 lines
interrupt vectors using new API calls with
pci_msix_alloc_irq_atandpci_msix_free_irq.Support both automatic and manual subfunction numbers. If no subfunction number is provided, use
xa_allocto pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of thedyn_portsxarray.Reviewed-by Wojciech Drewek <[email protected]>Co-developed-by Jacob Keller <[email protected]>Signed-off-by Jacob Keller <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ice/devlink/devlink.c +4
-0@@ -6,6 +6,7 @@#include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" @@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, }; +[...]
Quoted 22 lines
Quoted 22 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +22
-0+/** +* ice_devlink_port_fn_hw_addr_set - devlink handler for mac address set +* @port: pointer to devlink port +* @hw_addr: hw address to set +* @hw_addr_len: hw address length +* @extack: extack for reporting error messages +* +* Sets mac address for the port, verifies arguments and copies address +* to the subfunction structure. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_hw_addr_set (struct devlink_port *port,const u8 *hw_addr, +int hw_addr_len, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (hw_addr_len !=ETH_ALEN || !is_valid_ether_addr (hw_addr)) {Quoted 9 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c
Quoted 5 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +5
-0+NL_SET_ERR_MSG_MOD (extack,"Invalid ethernet address" ); +return -EADDRNOTAVAIL ; + } + +ether_addr_copy (dyn_port->hw_addr, hw_addr);How does this work? You copy the address to the internal structure, but where you update the HW?
Quoted 1 line
When the basic MAC filter is added in HW.
When is that. My point is, user can all this function at any time, and when he calls it, he expect it's applied right away. In case it can't be for example applied on activated SF, you should block the request.
Quoted 37 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +3
-0+ +return 0 ; +}[...]
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-0@@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev)ice_remove_arfs (pf);devl_lock (priv_to_devlink (pf)); +ice_dealloc_all_dynamic_ports (pf);ice_deinit_devlink (pf);ice_unload (pf);@@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi)Quoted 7 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c static int ice_up_complete(struct ice_vsi *vsi) · line 6687
Quoted 4 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-1if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev && vsi->type ==ICE_VSI_PF ) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) {I think this is some leftover, remove.
Yeah, thanks, will remove it.
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +0
-0ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);Signature · 1 line
2.42.0
Re: [iwl-next v1 03/14] ice: add basic devlink subfunctions support
Quoted 107 lines · Jiri Pirko
Quoted 106 lines · Fri, May 10, 2024 at 09:13:51AM CEST, [email protected] wrote:
Quoted 9 lines · Jiri Pirko
Quoted 8 lines · Tue, May 07, 2024 at 01:45:04PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev.
Quoted 8 lines
Quoted 5 lines
For now, subfunction is limited to only one Tx/Rx queue pair.
Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX
Interesting. You talk about actitation, yet you don't implement it here.
I will rephrase it. I meant that new VSI needs to be created even before any activation or configuration.
Quoted 49 lines
Quoted 49 lines
interrupt vectors using new API calls with
pci_msix_alloc_irq_atandpci_msix_free_irq.Support both automatic and manual subfunction numbers. If no subfunction number is provided, use
xa_allocto pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of thedyn_portsxarray.Reviewed-by Wojciech Drewek <[email protected]>Co-developed-by Jacob Keller <[email protected]>Signed-off-by Jacob Keller <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ice/devlink/devlink.c +4
-0@@ -6,6 +6,7 @@#include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" @@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, }; +[...]
Quoted 31 lines
Quoted 17 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +17
-0+/** +* ice_devlink_port_fn_hw_addr_set - devlink handler for mac address set +* @port: pointer to devlink port +* @hw_addr: hw address to set +* @hw_addr_len: hw address length +* @extack: extack for reporting error messages +* +* Sets mac address for the port, verifies arguments and copies address +* to the subfunction structure. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_hw_addr_set (struct devlink_port *port,const u8 *hw_addr, +int hw_addr_len, +struct netlink_ext_ack *extack) +{drivers/net/ethernet/intel/ice/devlink/devlink.c
Quoted 10 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +10
-0+struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (hw_addr_len !=ETH_ALEN || !is_valid_ether_addr (hw_addr)) { +NL_SET_ERR_MSG_MOD (extack,"Invalid ethernet address" ); +return -EADDRNOTAVAIL ; + } + +ether_addr_copy (dyn_port->hw_addr, hw_addr);How does this work? You copy the address to the internal structure, but where you update the HW?
Quoted 7 lines
Quoted 1 line
When the basic MAC filter is added in HW.
When is that. My point is, user can all this function at any time, and when he calls it, he expect it's applied right away. In case it can't be for example applied on activated SF, you should block the request.
Good point, I will block the request in this case. The filter is added during VSI configuration, in this case during SF activation.
Quoted 37 lines
Quoted 37 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +3
-0+ +return 0 ; +}[...]
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-0@@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev)ice_remove_arfs (pf);devl_lock (priv_to_devlink (pf)); +ice_dealloc_all_dynamic_ports (pf);ice_deinit_devlink (pf);ice_unload (pf);@@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi)Quoted 7 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c static int ice_up_complete(struct ice_vsi *vsi) · line 6687
Quoted 4 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +1
-1if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev && vsi->type ==ICE_VSI_PF ) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) {I think this is some leftover, remove.
Yeah, thanks, will remove it.
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/devlink/devlink.c +0
-0ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);Signature · 1 line
2.42.0
PATCH 4/14 ice: treat subfunction VSI the same as PF VSI
In reply to Michal SwiatkowskiWhen subfunction VSI is open the same code as for PF VSI should be executed. Also when up is complete. Reflect that in code by adding subfunction VSI to consideration.
In case of stopping, PF doesn't have additional tasks, so the same is with subfunction VSI.
--- drivers/net/ethernet/intel/ice/ice_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +3 -2
@@ -6684,7 +6684,8 @@ static int ice_up_complete(struct ice_vsi *vsi)if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - ((vsi->netdev && vsi->type ==ICE_VSI_PF ))) { + ((vsi->netdev && vsi->type ==ICE_VSI_PF ) || + (vsi->netdev && vsi->type ==ICE_VSI_SF ))) {ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);
@@ -7382,7 +7383,7 @@ int ice_vsi_open(struct ice_vsi *vsi)ice_vsi_cfg_netdev_tc (vsi, vsi->tc_cfg.ena_tc); -if (vsi->type ==ICE_VSI_PF ) { +if (vsi->type ==ICE_VSI_PF || vsi->type ==ICE_VSI_SF ) {/* Notify the stack of the actual queue counts. */ err =netif_set_real_num_tx_queues (vsi->netdev, vsi->num_txq);if (err)
Signature · 1 line
2.42.0
PATCH 5/14 ice: allocate devlink for subfunction
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Make devlink allocation function generic to use it for PF and for SF.
Add function for SF devlink port creation. It will be used in next patch.
Create header file for subfunction device. Define subfunction device structure there as it is needed for devlink allocation and port creation.
--- .../net/ethernet/intel/ice/devlink/devlink.c | 33 ++++++++++++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 50 +++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 3 ++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 21 ++++++++ 5 files changed, 108 insertions(+) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.h
drivers/net/ethernet/intel/ice/devlink/devlink.c +33 -0
@@ -10,6 +10,7 @@#include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" +#include "ice_sf_eth.h" /* context for devlink info version reporting */ struct ice_info_ctx {
@@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = { .port_new = ice_devlink_port_new, }; +static const struct devlink_ops ice_sf_devlink_ops; +static int ice_devlink_enable_roce_get (struct devlink *devlink,u32 id,struct devlink_param_gset_ctx *ctx)
@@ -1419,6 +1422,7 @@ static void ice_devlink_free(void *devlink_ptr)* Allocate a devlink instance for this device and return the private area as * the PF structure. The devlink memory is kept track of through devres by * adding an action to remove it when unwinding. +* */ struct ice_pf *ice_allocate_pf (struct device *dev) {
@@ -1435,6 +1439,35 @@ struct ice_pf *ice_allocate_pf(struct device *dev)return devlink_priv (devlink); } +/** +* ice_allocate_sf - Allocate devlink and return SF structure pointer +* @dev: the device to allocate for +* @pf: pointer to the PF structure +* +* Allocate a devlink instance for SF. +* +* Return: void pointer to allocated memory +*/ +struct ice_sf_priv *ice_allocate_sf (struct device *dev,struct ice_pf *pf) +{ +struct devlink *devlink; +int err; + + devlink =devlink_alloc_ns (&ice_sf_devlink_ops, +sizeof (struct ice_sf_priv ), +devlink_net (priv_to_devlink (pf)), dev); +if (!devlink) +return NULL ; + + err =devl_nested_devlink_set (priv_to_devlink (pf), devlink); +if (err) { +devlink_free (devlink); +return ERR_PTR (err); + } + +return devlink_priv (devlink); +} +/** * ice_devlink_register - Register devlink interface for this PF * @pf: the PF to register the devlink for.
drivers/net/ethernet/intel/ice/devlink/devlink.h +1 -0
@@ -5,6 +5,7 @@#define _ICE_DEVLINK_H_struct ice_pf *ice_allocate_pf (struct device *dev); +struct ice_sf_priv *ice_allocate_sf (struct device *dev,struct ice_pf *pf);void ice_devlink_register (struct ice_pf *pf);void ice_devlink_unregister (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +50 -0
56 lines not on this page · raw message
drivers/net/ethernet/intel/ice/devlink/devlink_port.h +3 -0
@@ -5,6 +5,7 @@#define _DEVLINK_PORT_H_#include "../ice.h" +#include "../ice_sf_eth.h" /** * struct ice_dynamic_port - Track dynamically added devlink port instance
@@ -33,6 +34,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf);void ice_devlink_destroy_vf_port (struct ice_vf *vf);int ice_devlink_create_sf_port (struct ice_dynamic_port *dyn_port);void ice_devlink_destroy_sf_port (struct ice_dynamic_port *dyn_port); +int ice_devlink_create_sf_dev_port (struct ice_sf_dev *sf_dev); +void ice_devlink_destroy_sf_dev_port (struct ice_sf_dev *sf_dev);#define ice_devlink_port_to_dyn (p) \ container_of(port, struct ice_dynamic_port, devlink_port)
drivers/net/ethernet/intel/ice/ice_sf_eth.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2024, Intel Corporation. */ + +#ifndef _ICE_SF_ETH_H_ +#define _ICE_SF_ETH_H_ + +#include <linux/auxiliary_bus.h> +#include "ice.h" + +struct ice_sf_dev { +struct auxiliary_device adev; +struct ice_dynamic_port *dyn_port; +struct ice_sf_priv *priv; +}; + +struct ice_sf_priv { +struct ice_sf_dev *dev; +struct devlink_port devlink_port; +}; + +#endif /* _ICE_SF_ETH_H_ */
Signature · 1 line
2.42.0
PATCH 6/14 ice: base subfunction aux driver
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Implement subfunction driver. It is probe when subfunction port is activated.
VSI is already created. During the probe VSI is being configured. MAC unicast and broadcast filter is added to allow traffic to pass.
Store subfunction pointer in VSI struct. The same is done for VF pointer. Make union of subfunction and VF pointer as only one of them can be set with one VSI.
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 7 +- drivers/net/ethernet/intel/ice/ice_main.c | 10 ++ drivers/net/ethernet/intel/ice/ice_sf_eth.c | 139 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 9 ++ 5 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.c
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -31,6 +31,7 @@ ice-y := ice_main.o \ ice_idc.o \ devlink/devlink.o \ devlink/devlink_port.o \ + ice_sf_eth.o \ ice_ddp.o \ ice_fw_update.o \ ice_lag.o \
drivers/net/ethernet/intel/ice/ice.h +6 -1
@@ -450,7 +450,12 @@ struct ice_vsi {struct_group_tagged (ice_vsi_cfg_params, params, struct ice_port_info *port_info; /* back pointer to port_info */struct ice_channel *ch;/* VSI's channel structure, may be NULL */ -struct ice_vf *vf;/* VF associated with this VSI, may be NULL */ +union { +/* VF associated with this VSI, may be NULL */ +struct ice_vf *vf; +/* SF associated with this VSI, may be NULL */ +struct ice_dynamic_port *sf; + };u32 flags;/* VSI flags used for rebuild and configuration */ enum ice_vsi_type type;/* the type of the VSI */ );
drivers/net/ethernet/intel/ice/ice_main.c +10 -0
@@ -15,6 +15,7 @@#include "ice_dcb_nl.h" #include "devlink/devlink.h" #include "devlink/devlink_port.h" +#include "ice_sf_eth.h" #include "ice_hwmon.h" /* Including ice_trace.h with CREATE_TRACE_POINTS defined will generate the * ice tracepoint functions. This must be done exactly once across the
@@ -5864,8 +5865,16 @@ static int __init ice_module_init(void) goto err_dest_lag_wq; } + status =ice_sf_driver_register (); +if (status) { +pr_err ("Failed to register SF driver, err %d\n" , status); + goto err_sf_driver; + } +return 0 ; +err_sf_driver: +pci_unregister_driver (&ice_driver); err_dest_lag_wq:destroy_workqueue (ice_lag_wq);ice_debugfs_exit ();
@@ -5883,6 +5892,7 @@ module_init(ice_module_init);*/ static void __exit ice_module_exit(void) { +ice_sf_driver_unregister ();pci_unregister_driver (&ice_driver);ice_debugfs_exit ();destroy_workqueue (ice_wq);
drivers/net/ethernet/intel/ice/ice_sf_eth.c new file +139 -0
139 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sf_eth.h +9 -0
@@ -18,4 +18,13 @@ struct ice_sf_priv {struct devlink_port devlink_port; }; +static inline struct +ice_sf_dev *ice_adev_to_sf_dev (struct auxiliary_device *adev) +{ + return container_of(adev, struct ice_sf_dev, adev); +} + +int ice_sf_driver_register (void ); +void ice_sf_driver_unregister (void ); +#endif /* _ICE_SF_ETH_H_ */
Signature · 1 line
2.42.0
Re: [iwl-next v1 06/14] ice: base subfunction aux driver
Quoted 8 lines · Tue, May 07, 2024 at 01:45:07PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement subfunction driver. It is probe when subfunction port is activated.
VSI is already created. During the probe VSI is being configured. MAC unicast and broadcast filter is added to allow traffic to pass.
Quoted 7 lines
Store subfunction pointer in VSI struct. The same is done for VF pointer. Make union of subfunction and VF pointer as only one of them can be set with one VSI.
Reviewed-by Jiri Pirko <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>
Perhaps it would make things clearer for reviewer to have all patches related to sf auxdev/devlink/netdev at the end of the patchset, after activation patch. Not sure why you want to mix it here.
Re: [iwl-next v1 06/14] ice: base subfunction aux driver
Quoted 13 lines · Jiri Pirko
Quoted 12 lines · Tue, May 07, 2024 at 01:45:07PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement subfunction driver. It is probe when subfunction port is activated.
VSI is already created. During the probe VSI is being configured. MAC unicast and broadcast filter is added to allow traffic to pass.
Store subfunction pointer in VSI struct. The same is done for VF pointer. Make union of subfunction and VF pointer as only one of them can be set with one VSI.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Jiri Pirko <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>Perhaps it would make things clearer for reviewer to have all patches related to sf auxdev/devlink/netdev at the end of the patchset, after activation patch. Not sure why you want to mix it here.
I need this code to use it in port representor implementation. You suggested in previous review to move activation at the end [1].
[1] https://lore.kernel.org/netdev/Zhje0mQgQTMXwICb@nanopsycho/
Re: [iwl-next v1 06/14] ice: base subfunction aux driver
Quoted 18 lines · Fri, May 10, 2024 at 09:20:51AM CEST, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
Quoted 15 lines · Tue, May 07, 2024 at 01:45:07PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Implement subfunction driver. It is probe when subfunction port is activated.
VSI is already created. During the probe VSI is being configured. MAC unicast and broadcast filter is added to allow traffic to pass.
Store subfunction pointer in VSI struct. The same is done for VF pointer. Make union of subfunction and VF pointer as only one of them can be set with one VSI.
Reviewed-by Jiri Pirko <[email protected]>Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>
Quoted 6 lines
Quoted 3 lines
Perhaps it would make things clearer for reviewer to have all patches related to sf auxdev/devlink/netdev at the end of the patchset, after activation patch. Not sure why you want to mix it here.
I need this code to use it in port representor implementation. You suggested in previous review to move activation at the end [1].
Yeah, I just thought that sfdev patches could be separate. Nevermind then.
Quoted 2 lines
[1] https://lore.kernel.org/netdev/Zhje0mQgQTMXwICb@nanopsycho/
PATCH 7/14 ice: implement netdev for subfunction
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Configure netdevice for subfunction usecase. Mostly it is reusing ops from the PF netdevice.
SF netdev is linked to devlink port registered after SF activation.
--- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 85 ++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sf_eth.c +84 -1
@@ -2,11 +2,85 @@/* Copyright (c) 2024, Intel Corporation. */ #include "ice.h" #include "ice_lib.h" +#include "ice_txrx.h" #include "ice_fltr.h" #include "ice_sf_eth.h" #include "devlink/devlink_port.h" #include "devlink/devlink.h" +static const struct net_device_ops ice_sf_netdev_ops = { + .ndo_open = ice_open, + .ndo_stop = ice_stop, + .ndo_start_xmit = ice_start_xmit, + .ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid, + .ndo_change_mtu = ice_change_mtu, + .ndo_get_stats64 = ice_get_stats64, + .ndo_tx_timeout = ice_tx_timeout, + .ndo_bpf = ice_xdp, + .ndo_xdp_xmit = ice_xdp_xmit, + .ndo_xsk_wakeup = ice_xsk_wakeup, +}; + +/** +* ice_sf_cfg_netdev - Allocate, configure and register a netdev +* @dyn_port: subfunction associated with configured netdev +* @devlink_port: subfunction devlink port to be linked with netdev +* +* Return: 0 on success, negative value on failure +*/ +static int ice_sf_cfg_netdev (struct ice_dynamic_port *dyn_port, +struct devlink_port *devlink_port) +{ +struct ice_vsi *vsi = dyn_port->vsi; +struct ice_netdev_priv *np; +struct net_device *netdev; +int err; + + netdev =alloc_etherdev_mqs (sizeof (*np), vsi->alloc_txq, + vsi->alloc_rxq); +if (!netdev) +return -ENOMEM ; + +SET_NETDEV_DEV (netdev, &vsi->back->pdev->dev); +set_bit (ICE_VSI_NETDEV_ALLOCD , vsi->state); + vsi->netdev = netdev; + np =netdev_priv (netdev); + np->vsi = vsi; + +ice_set_netdev_features (netdev); + + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY | +NETDEV_XDP_ACT_RX_SG ; + +eth_hw_addr_set (netdev, dyn_port->hw_addr); +ether_addr_copy (netdev->perm_addr, dyn_port->hw_addr); + netdev->netdev_ops = &ice_sf_netdev_ops; +SET_NETDEV_DEVLINK_PORT (netdev, devlink_port); + + err =register_netdev (netdev); +if (err) { +free_netdev (netdev); + vsi->netdev =NULL ; +return -ENOMEM ; + } +set_bit (ICE_VSI_NETDEV_REGISTERED , vsi->state); +netif_carrier_off (netdev); +netif_tx_stop_all_queues (netdev); + +return 0 ; +} + +static void ice_sf_decfg_netdev (struct ice_vsi *vsi) +{ +unregister_netdev (vsi->netdev); +clear_bit (ICE_VSI_NETDEV_REGISTERED , vsi->state); +free_netdev (vsi->netdev); + vsi->netdev =NULL ; +clear_bit (ICE_VSI_NETDEV_ALLOCD , vsi->state); +} +/** * ice_sf_dev_probe - subfunction driver probe function * @adev: pointer to the auxiliary device
@@ -57,10 +131,16 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev, goto err_vsi_decfg; } + err =ice_sf_cfg_netdev (dyn_port, &sf_dev->priv->devlink_port); +if (err) { +dev_err (dev,"Subfunction netdev config failed" ); + goto err_devlink_destroy; + } + err =devl_port_fn_devlink_set (&dyn_port->devlink_port, devlink);if (err) {dev_err (dev,"Can't link devlink instance to SF devlink port" ); - goto err_devlink_destroy; + goto err_netdev_decfg; }ice_napi_add (vsi);
@@ -70,6 +150,8 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,return 0 ; +err_netdev_decfg: +ice_sf_decfg_netdev (vsi); err_devlink_destroy:ice_devlink_destroy_sf_dev_port (sf_dev); err_vsi_decfg:
@@ -98,6 +180,7 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)ice_vsi_close (vsi); +ice_sf_decfg_netdev (vsi);ice_devlink_destroy_sf_dev_port (sf_dev);devl_unregister (devlink);devl_unlock (devlink);
Signature · 1 line
2.42.0
PATCH 8/14 ice: create port representor for SF
In reply to Michal SwiatkowskiStore subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them.
Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function.
Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure.
Create port representor when subfunction port is created.
Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic.
--- .../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +3 -3
@@ -495,7 +495,7 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)struct ice_pf *pf = dyn_port->pf;xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf); -devl_port_unregister (devlink_port); +ice_eswitch_detach_sf (pf, dyn_port);ice_vsi_free (dyn_port->vsi);xa_erase (&pf->dyn_ports, dyn_port->vsi->idx);kfree (dyn_port);
@@ -786,9 +786,9 @@ ice_alloc_dynamic_port(struct ice_pf *pf, goto unroll_vsi_alloc; } - err =ice_devlink_create_sf_port (dyn_port); + err =ice_eswitch_attach_sf (pf, dyn_port);if (err) { -NL_SET_ERR_MSG_MOD (extack,"Port registration failed" ); +NL_SET_ERR_MSG_MOD (extack,"Failed to attach SF to eswitch" ); goto unroll_xa_insert; }
drivers/net/ethernet/intel/ice/devlink/devlink_port.h +1 -0
@@ -23,6 +23,7 @@ struct ice_dynamic_port {struct devlink_port devlink_port;struct ice_pf *pf;struct ice_vsi *vsi; +unsigned long repr_id;u32 sfnum; };
drivers/net/ethernet/intel/ice/ice_eswitch.c +64 -21
144 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_eswitch.h +17 -5
@@ -5,11 +5,13 @@#define _ICE_ESWITCH_H_#include <net/devlink.h> +#include "devlink/devlink_port.h" #ifdef CONFIG_ICE_SWITCHDEV -void ice_eswitch_detach (struct ice_pf *pf,struct ice_vf *vf); -int -ice_eswitch_attach (struct ice_pf *pf,struct ice_vf *vf); +void ice_eswitch_detach_vf (struct ice_pf *pf,struct ice_vf *vf); +void ice_eswitch_detach_sf (struct ice_pf *pf,struct ice_dynamic_port *sf); +int ice_eswitch_attach_vf (struct ice_pf *pf,struct ice_vf *vf); +int ice_eswitch_attach_sf (struct ice_pf *pf,struct ice_dynamic_port *sf);void ice_eswitch_rebuild (struct ice_pf *pf);int ice_eswitch_mode_get (struct devlink *devlink,u16 *mode);
@@ -32,10 +34,20 @@ struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring,int ice_eswitch_cfg_vsi (struct ice_vsi *vsi,const u8 *mac);void ice_eswitch_decfg_vsi (struct ice_vsi *vsi,const u8 *mac);#else /* CONFIG_ICE_SWITCHDEV */ -static inline void ice_eswitch_detach (struct ice_pf *pf,struct ice_vf *vf) { } +static inline void +ice_eswitch_detach_vf (struct ice_pf *pf,struct ice_vf *vf) { } + +static inline void +ice_eswitch_detach_sf (struct ice_pf *pf,struct ice_dynamic_port *sf) { } + +static inline int +ice_eswitch_attach_vf (struct ice_pf *pf,struct ice_vf *vf) +{ +return -EOPNOTSUPP ; +}static inline int -ice_eswitch_attach (struct ice_pf *pf,struct ice_vf *vf) +ice_eswitch_attach_sf (struct ice_pf *pf,struct ice_dynamic_port *sf) {return -EOPNOTSUPP ; }
drivers/net/ethernet/intel/ice/ice_repr.c +80 -44
181 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_repr.h +18 -3
@@ -15,19 +15,34 @@ struct ice_repr_pcpu_stats {u64 tx_drops; }; +enum ice_repr_type { +ICE_REPR_TYPE_VF , +ICE_REPR_TYPE_SF , +}; +struct ice_repr {struct ice_vsi *src_vsi; -struct ice_vf *vf;struct net_device *netdev;struct metadata_dst *dst;struct ice_esw_br_port *br_port;struct ice_repr_pcpu_stats __percpu *stats;u32 id;u8 parent_mac[ETH_ALEN ]; +enum ice_repr_type type; +union { +struct ice_vf *vf; +struct ice_dynamic_port *sf; + }; +struct { +int (*add)(struct ice_repr *repr); +void (*rem)(struct ice_repr *repr); + } ops; }; -struct ice_repr *ice_repr_add_vf (struct ice_vf *vf); -void ice_repr_rem_vf (struct ice_repr *repr); +struct ice_repr *ice_repr_create_vf (struct ice_vf *vf); +struct ice_repr *ice_repr_create_sf (struct ice_dynamic_port *sf); + +void ice_repr_destroy (struct ice_repr *repr);void ice_repr_start_tx_queues (struct ice_repr *repr);void ice_repr_stop_tx_queues (struct ice_repr *repr);
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -2
@@ -175,7 +175,7 @@ void ice_free_vfs(struct ice_pf *pf)ice_for_each_vf (pf, bkt, vf) {mutex_lock (&vf->cfg_lock); -ice_eswitch_detach (pf, vf); +ice_eswitch_detach_vf (pf, vf);ice_dis_vf_qs (vf);if (test_bit (ICE_VF_STATE_INIT , vf->vf_states)) {
@@ -598,7 +598,7 @@ static int ice_start_vfs(struct ice_pf *pf) goto teardown; } - retval =ice_eswitch_attach (pf, vf); + retval =ice_eswitch_attach_vf (pf, vf);if (retval) {dev_err (ice_pf_to_dev (pf),"Failed to attach VF %d to eswitch, error %d" , vf->vf_id, retval);
drivers/net/ethernet/intel/ice/ice_vf_lib.c +2 -2
@@ -766,7 +766,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)ice_for_each_vf (pf, bkt, vf) {mutex_lock (&vf->cfg_lock); -ice_eswitch_detach (pf, vf); +ice_eswitch_detach_vf (pf, vf); vf->driver_caps =0 ;ice_vc_set_default_allowlist (vf);
@@ -782,7 +782,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)ice_vf_rebuild_vsi (vf);ice_vf_post_vsi_rebuild (vf); -ice_eswitch_attach (pf, vf); +ice_eswitch_attach_vf (pf, vf);mutex_unlock (&vf->cfg_lock); }
Signature · 1 line
2.42.0
Re: [iwl-next v1 08/14] ice: create port representor for SF
Quoted 19 lines · Tue, May 07, 2024 at 01:45:09PM CEST, [email protected] wrote:
Store subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them.
Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function.
Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure.
Create port representor when subfunction port is created.
Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
Quoted 9 lines
.../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-)
This calls for a split to at least 2 patches. One patch to prepare and one to add the SF support?
Re: [iwl-next v1 08/14] ice: create port representor for SF
Quoted 30 lines · Jiri Pirko
Quoted 19 lines · Tue, May 07, 2024 at 01:45:09PM CEST, [email protected] wrote:
Store subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them.
Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function.
Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure.
Create port representor when subfunction port is created.
Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
Quoted 9 lines
.../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-)
Quoted 2 lines
This calls for a split to at least 2 patches. One patch to prepare and one to add the SF support?
Is 187 insertions and 80 deletions too many for one patch? Or the problem is with number of files changed?
I don't see what here can be moved to preparation part as most changes depends on each other. Do you want me to have one patch with unused functions that are adding/removing SF repr and another with calling them?
Thanks,
Michal
Re: [iwl-next v1 08/14] ice: create port representor for SF
Quoted 31 lines · Fri, May 10, 2024 at 09:31:15AM CEST, [email protected] wrote:
Quoted 30 lines · Jiri Pirko
Quoted 28 lines · Tue, May 07, 2024 at 01:45:09PM CEST, [email protected] wrote:
Store subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them.
Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function.
Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure.
Create port representor when subfunction port is created.
Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-)
Quoted 5 lines
Quoted 2 lines
This calls for a split to at least 2 patches. One patch to prepare and one to add the SF support?
Is 187 insertions and 80 deletions too many for one patch? Or the problem is with number of files changed?
The patch is hard to follow, that's the problem.
Quoted 8 lines
I don't see what here can be moved to preparation part as most changes depends on each other. Do you want me to have one patch with unused functions that are adding/removing SF repr and another with calling them?
Thanks,
Michal
Re: [Intel-wired-lan] [iwl-next v1 08/14] ice: create port representor for SF
Quoted 32 lines · Jiri Pirko
Quoted 31 lines · Fri, May 10, 2024 at 09:31:15AM CEST, [email protected] wrote:
Quoted 30 lines · Jiri Pirko
Quoted 28 lines · Tue, May 07, 2024 at 01:45:09PM CEST, [email protected] wrote:
Store subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them.
Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function.
Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure.
Create port representor when subfunction port is created.
Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This calls for a split to at least 2 patches. One patch to prepare and one to add the SF support?
Is 187 insertions and 80 deletions too many for one patch? Or the problem is with number of files changed?
The patch is hard to follow, that's the problem.
Ok, I will do my best to make it easier to read in next version.
Quoted 9 lines
Quoted 9 lines
I don't see what here can be moved to preparation part as most changes depends on each other. Do you want me to have one patch with unused functions that are adding/removing SF repr and another with calling them?
Thanks,
Michal
PATCH 9/14 ice: don't set target VSI for subfunction
In reply to Michal SwiatkowskiAdd check for subfunction before setting target VSI. It is needed for PF in switchdev mode but not for subfunction (even in switchdev mode).
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -2405,7 +2405,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring) ICE_TXD_CTX_QW1_CMD_S);ice_tstamp (tx_ring, skb, first, &offload); -if (ice_is_switchdev_running (vsi->back)) +if (ice_is_switchdev_running (vsi->back) && vsi->type !=ICE_VSI_SF )ice_eswitch_set_target_vsi (skb, &offload);if (offload.cd_qw1 &ICE_TX_DESC_DTYPE_CTX ) {
Signature · 1 line
2.42.0
PATCH 10/14 ice: check if SF is ready in ethtool ops
In reply to Michal SwiatkowskiNow there is another type of port representor. Correct checking if parent device is ready to reflect also new PR type.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +++---- drivers/net/ethernet/intel/ice/ice_repr.c | 12 ++++++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +3 -4
@@ -4070,7 +4070,7 @@ ice_repr_get_drvinfo(struct net_device *netdev, {struct ice_repr *repr =ice_netdev_to_repr (netdev); -if (ice_check_vf_ready_for_cfg (repr->vf)) +if (repr->ops.ready (repr))return ;__ice_get_drvinfo (netdev, drvinfo, repr->src_vsi);
@@ -4082,8 +4082,7 @@ ice_repr_get_strings(struct net_device *netdev, u32 stringset, u8 *data)struct ice_repr *repr =ice_netdev_to_repr (netdev);/* for port representors only ETH_SS_STATS is supported */ -if (ice_check_vf_ready_for_cfg (repr->vf) || - stringset !=ETH_SS_STATS ) +if (repr->ops.ready (repr) || stringset !=ETH_SS_STATS )return ;__ice_get_strings (netdev, stringset, data, repr->src_vsi);
@@ -4096,7 +4095,7 @@ ice_repr_get_ethtool_stats(struct net_device *netdev, {struct ice_repr *repr =ice_netdev_to_repr (netdev); -if (ice_check_vf_ready_for_cfg (repr->vf)) +if (repr->ops.ready (repr))return ;__ice_get_ethtool_stats (netdev, stats, data, repr->src_vsi);
drivers/net/ethernet/intel/ice/ice_repr.c +12 -0
@@ -283,6 +283,16 @@ ice_repr_reg_netdev(struct net_device *netdev)return register_netdev (netdev); } +static int ice_repr_ready_vf (struct ice_repr *repr) +{ +return !ice_check_vf_ready_for_cfg (repr->vf); +} + +static int ice_repr_ready_sf (struct ice_repr *repr) +{ +return !repr->sf->active; +} +/** * ice_repr_destroy - remove representor from VF * @repr: pointer to representor structure
@@ -412,6 +422,7 @@ struct ice_repr *ice_repr_create_vf(struct ice_vf *vf) repr->vf = vf; repr->ops.add = ice_repr_add_vf; repr->ops.rem = ice_repr_rem_vf; + repr->ops.ready = ice_repr_ready_vf;ether_addr_copy (repr->parent_mac, vf->hw_lan_addr);
@@ -450,6 +461,7 @@ struct ice_repr *ice_repr_create_sf(struct ice_dynamic_port *sf) repr->sf = sf; repr->ops.add = ice_repr_add_sf; repr->ops.rem = ice_repr_rem_sf; + repr->ops.ready = ice_repr_ready_sf;ether_addr_copy (repr->parent_mac, sf->hw_addr);
drivers/net/ethernet/intel/ice/ice_repr.h +1 -0
@@ -36,6 +36,7 @@ struct ice_repr {struct {int (*add)(struct ice_repr *repr);void (*rem)(struct ice_repr *repr); +int (*ready)(struct ice_repr *repr); } ops; };
Signature · 1 line
2.42.0
PATCH 11/14 ice: netdevice ops for SF representor
In reply to Michal SwiatkowskiSubfunction port representor needs the basic netdevice ops to work correctly. Create them.
--- drivers/net/ethernet/intel/ice/ice_repr.c | 57 +++++++++++++++++------ 1 file changed, 43 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_repr.c +43 -14
@@ -59,12 +59,13 @@ 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_repr *repr = np->repr;struct ice_eth_stats *eth_stats;struct ice_vsi *vsi; -if (ice_is_vf_disabled (np->repr->vf)) +if (repr->ops.ready (repr))return ; - vsi = np->repr->src_vsi; + vsi = repr->src_vsi;ice_update_vsi_stats (vsi); eth_stats = &vsi->eth_stats;
@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) }/** -* ice_repr_open - Enable port representor's network interface +* ice_repr_vf_open - Enable port representor's network interface * @netdev: network interface device structure * * The open entry point is called when a port representor's network
@@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_open (struct net_device *netdev) +static int ice_repr_vf_open (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;
@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_open (struct net_device *netdev) +{ +netif_carrier_on (netdev); +netif_tx_start_all_queues (netdev); + +return 0 ; +} +/** -* ice_repr_stop - Disable port representor's network interface +* ice_repr_vf_stop - Disable port representor's network interface * @netdev: network interface device structure * * The stop entry point is called when a port representor's network
@@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_stop (struct net_device *netdev) +static int ice_repr_vf_stop (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;
@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_stop (struct net_device *netdev) +{ +netif_carrier_off (netdev); +netif_tx_stop_all_queues (netdev); + +return 0 ; +} +/** * ice_repr_sp_stats64 - get slow path stats for port representor * @dev: network interface device structure
@@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } -static const struct net_device_ops ice_repr_netdev_ops = { +static const struct net_device_ops ice_repr_vf_netdev_ops = { + .ndo_get_stats64 = ice_repr_get_stats64, + .ndo_open = ice_repr_vf_open, + .ndo_stop = ice_repr_vf_stop, + .ndo_start_xmit = ice_eswitch_port_start_xmit, + .ndo_setup_tc = ice_repr_setup_tc, + .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, + .ndo_get_offload_stats = ice_repr_ndo_get_offload_stats, +}; + +static const struct net_device_ops ice_repr_sf_netdev_ops = { .ndo_get_stats64 = ice_repr_get_stats64, - .ndo_open = ice_repr_open, - .ndo_stop = ice_repr_stop, + .ndo_open = ice_repr_sf_open, + .ndo_stop = ice_repr_sf_stop, .ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_setup_tc = ice_repr_setup_tc, .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats,
@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = {*/ bool ice_is_port_repr_netdev (const struct net_device *netdev) { -return netdev && (netdev->netdev_ops == &ice_repr_netdev_ops); +return netdev && (netdev->netdev_ops == &ice_repr_vf_netdev_ops || + netdev->netdev_ops == &ice_repr_sf_netdev_ops); }/** * ice_repr_reg_netdev - register port representor netdev * @netdev: pointer to port representor netdev +* @ops: new ops for netdev */ static int -ice_repr_reg_netdev (struct net_device *netdev) +ice_repr_reg_netdev (struct net_device *netdev,const struct net_device_ops *ops) {eth_hw_addr_random (netdev); - netdev->netdev_ops = &ice_repr_netdev_ops; + netdev->netdev_ops = ops;ice_set_ethtool_repr_ops (netdev); netdev->hw_features |=NETIF_F_HW_TC ;
@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &vf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_vf_netdev_ops);if (err) goto err_netdev;
@@ -439,7 +468,7 @@ static int ice_repr_add_sf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &sf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_sf_netdev_ops);if (err) goto err_netdev;
Signature · 1 line
2.42.0
Re: [iwl-next v1 11/14] ice: netdevice ops for SF representor
Subject does not have verb. Please add it.
Otherwise, the patch looks ok.
Quoted 159 lines · Tue, May 07, 2024 at 01:45:12PM CEST, [email protected] wrote:
Subfunction port representor needs the basic netdevice ops to work correctly. Create them.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_repr.c| 57 +++++++++++++++++------1 file changed, 43 insertions(+), 14 deletions(-)drivers/net/ethernet/intel/ice/ice_repr.c +39
-10@@ -59,12 +59,13 @@ 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_repr *repr = np->repr;struct ice_eth_stats *eth_stats;struct ice_vsi *vsi; -if (ice_is_vf_disabled (np->repr->vf)) +if (repr->ops.ready (repr))return ; - vsi = np->repr->src_vsi; + vsi = repr->src_vsi;ice_update_vsi_stats (vsi); eth_stats = &vsi->eth_stats;@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) }/** -* ice_repr_open - Enable port representor's network interface +* ice_repr_vf_open - Enable port representor's network interface * @netdev: network interface device structure * * The open entry point is called when a port representor's network @@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_open (struct net_device *netdev) +static int ice_repr_vf_open (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_open (struct net_device *netdev) +{ +netif_carrier_on (netdev); +netif_tx_start_all_queues (netdev); + +return 0 ; +} +/** -* ice_repr_stop - Disable port representor's network interface +* ice_repr_vf_stop - Disable port representor's network interface * @netdev: network interface device structure * * The stop entry point is called when a port representor's network @@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_stop (struct net_device *netdev) +static int ice_repr_vf_stop (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_stop (struct net_device *netdev) +{ +netif_carrier_off (netdev); +netif_tx_stop_all_queues (netdev); + +return 0 ; +} +/** * ice_repr_sp_stats64 - get slow path stats for port representor * @dev: network interface device structure @@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } -static const struct net_device_ops ice_repr_netdev_ops = { +static const struct net_device_ops ice_repr_vf_netdev_ops = { + .ndo_get_stats64 = ice_repr_get_stats64, + .ndo_open = ice_repr_vf_open, + .ndo_stop = ice_repr_vf_stop, + .ndo_start_xmit = ice_eswitch_port_start_xmit, + .ndo_setup_tc = ice_repr_setup_tc, + .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, + .ndo_get_offload_stats = ice_repr_ndo_get_offload_stats, +}; + +static const struct net_device_ops ice_repr_sf_netdev_ops = { .ndo_get_stats64 = ice_repr_get_stats64, - .ndo_open = ice_repr_open, - .ndo_stop = ice_repr_stop, + .ndo_open = ice_repr_sf_open, + .ndo_stop = ice_repr_sf_stop, .ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_setup_tc = ice_repr_setup_tc, .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats,@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = {*/ bool ice_is_port_repr_netdev (const struct net_device *netdev) { -return netdev && (netdev->netdev_ops == &ice_repr_netdev_ops); +return netdev && (netdev->netdev_ops == &ice_repr_vf_netdev_ops || + netdev->netdev_ops == &ice_repr_sf_netdev_ops); }/** * ice_repr_reg_netdev - register port representor netdev * @netdev: pointer to port representor netdev +* @ops: new ops for netdev */ static int
drivers/net/ethernet/intel/ice/ice_repr.c +1
-1-ice_repr_reg_netdev(struct net_device *netdev) +ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops){ eth_hw_addr_random(netdev);drivers/net/ethernet/intel/ice/ice_repr.c +1
-1- netdev->netdev_ops = &ice_repr_netdev_ops; + netdev->netdev_ops = ops;ice_set_ethtool_repr_ops(netdev); netdev->hw_features |= NETIF_F_HW_TC;drivers/net/ethernet/intel/ice/ice_repr.c +2
-2@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &vf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_vf_netdev_ops);if (err) goto err_netdev;@@ -439,7 +468,7 @@ static int ice_repr_add_sf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &sf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_sf_netdev_ops);if (err) goto err_netdev;Signature · 1 line
2.42.0
Re: [iwl-next v1 11/14] ice: netdevice ops for SF representor
Quoted 3 lines · Jiri Pirko
Subject does not have verb. Please add it.
Otherwise, the patch looks ok.
Thanks, will add sth like "implement".
Quoted 165 lines
Reviewed-by Jiri Pirko <[email protected]>Quoted 159 lines · Tue, May 07, 2024 at 01:45:12PM CEST, [email protected] wrote:
Subfunction port representor needs the basic netdevice ops to work correctly. Create them.
Reviewed-by Wojciech Drewek <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_repr.c| 57 +++++++++++++++++------1 file changed, 43 insertions(+), 14 deletions(-)drivers/net/ethernet/intel/ice/ice_repr.c +39
-10@@ -59,12 +59,13 @@ 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_repr *repr = np->repr;struct ice_eth_stats *eth_stats;struct ice_vsi *vsi; -if (ice_is_vf_disabled (np->repr->vf)) +if (repr->ops.ready (repr))return ; - vsi = np->repr->src_vsi; + vsi = repr->src_vsi;ice_update_vsi_stats (vsi); eth_stats = &vsi->eth_stats;@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) }/** -* ice_repr_open - Enable port representor's network interface +* ice_repr_vf_open - Enable port representor's network interface * @netdev: network interface device structure * * The open entry point is called when a port representor's network @@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_open (struct net_device *netdev) +static int ice_repr_vf_open (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_open (struct net_device *netdev) +{ +netif_carrier_on (netdev); +netif_tx_start_all_queues (netdev); + +return 0 ; +} +/** -* ice_repr_stop - Disable port representor's network interface +* ice_repr_vf_stop - Disable port representor's network interface * @netdev: network interface device structure * * The stop entry point is called when a port representor's network @@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev)* * Returns 0 on success */ -static int ice_repr_stop (struct net_device *netdev) +static int ice_repr_vf_stop (struct net_device *netdev) {struct ice_repr *repr =ice_netdev_to_repr (netdev);struct ice_vf *vf;@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev)return 0 ; } +static int ice_repr_sf_stop (struct net_device *netdev) +{ +netif_carrier_off (netdev); +netif_tx_stop_all_queues (netdev); + +return 0 ; +} +/** * ice_repr_sp_stats64 - get slow path stats for port representor * @dev: network interface device structure @@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } -static const struct net_device_ops ice_repr_netdev_ops = { +static const struct net_device_ops ice_repr_vf_netdev_ops = { + .ndo_get_stats64 = ice_repr_get_stats64, + .ndo_open = ice_repr_vf_open, + .ndo_stop = ice_repr_vf_stop, + .ndo_start_xmit = ice_eswitch_port_start_xmit, + .ndo_setup_tc = ice_repr_setup_tc, + .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, + .ndo_get_offload_stats = ice_repr_ndo_get_offload_stats, +}; + +static const struct net_device_ops ice_repr_sf_netdev_ops = { .ndo_get_stats64 = ice_repr_get_stats64, - .ndo_open = ice_repr_open, - .ndo_stop = ice_repr_stop, + .ndo_open = ice_repr_sf_open, + .ndo_stop = ice_repr_sf_stop, .ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_setup_tc = ice_repr_setup_tc, .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats,@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = {*/ bool ice_is_port_repr_netdev (const struct net_device *netdev) { -return netdev && (netdev->netdev_ops == &ice_repr_netdev_ops); +return netdev && (netdev->netdev_ops == &ice_repr_vf_netdev_ops || + netdev->netdev_ops == &ice_repr_sf_netdev_ops); }/** * ice_repr_reg_netdev - register port representor netdev * @netdev: pointer to port representor netdev +* @ops: new ops for netdev */ static int
drivers/net/ethernet/intel/ice/ice_repr.c +1
-1-ice_repr_reg_netdev(struct net_device *netdev) +ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops){ eth_hw_addr_random(netdev);drivers/net/ethernet/intel/ice/ice_repr.c +1
-1- netdev->netdev_ops = &ice_repr_netdev_ops; + netdev->netdev_ops = ops;ice_set_ethtool_repr_ops(netdev); netdev->hw_features |= NETIF_F_HW_TC;drivers/net/ethernet/intel/ice/ice_repr.c +2
-2@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &vf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_vf_netdev_ops);if (err) goto err_netdev;@@ -439,7 +468,7 @@ static int ice_repr_add_sf(struct ice_repr *repr)return err;SET_NETDEV_DEVLINK_PORT (repr->netdev, &sf->devlink_port); - err =ice_repr_reg_netdev (repr->netdev); + err =ice_repr_reg_netdev (repr->netdev, &ice_repr_sf_netdev_ops);if (err) goto err_netdev;Signature · 1 line
2.42.0
PATCH 12/14 ice: support subfunction devlink Tx topology
In reply to Michal SwiatkowskiFlow for creating Tx topology is the same as for VF port representors, but the devlink port is stored in different place (sf->devlink_port).
When creating VF devlink lock isn't taken, when creating subfunction it is. Setting Tx topology function needs to take this lock, check if it was taken before to not do it twice.
--- drivers/net/ethernet/intel/ice/devlink/devlink.c | 12 ++++++++++++ .../net/ethernet/intel/ice/devlink/devlink_port.c | 3 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 12 +++++++----- 3 files changed, 21 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +12 -0
@@ -746,6 +746,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node struct ice_sched_node *tc_node, struct ice_pf *pf) { struct devlink_rate *rate_node = NULL; +struct ice_dynamic_port *sf;struct ice_vf *vf;int i;
@@ -757,6 +758,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node/* create root node */ rate_node =devl_rate_node_create (devlink, node, node->name,NULL ); }else if (node->vsi_handle && + pf->vsi[node->vsi_handle]->type ==ICE_VSI_VF && pf->vsi[node->vsi_handle]->vf) { vf = pf->vsi[node->vsi_handle]->vf;if (!vf->devlink_port.devlink_rate)
@@ -765,6 +767,16 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node*/ devl_rate_leaf_create (&vf->devlink_port, node, node->parent->rate_node); + }else if (node->vsi_handle && + pf->vsi[node->vsi_handle]->type ==ICE_VSI_SF && + pf->vsi[node->vsi_handle]->sf) { + sf = pf->vsi[node->vsi_handle]->sf; +if (!sf->devlink_port.devlink_rate) +/* leaf nodes doesn't have children +* so we don't set rate_node +*/ +devl_rate_leaf_create (&sf->devlink_port, node, + node->parent->rate_node); }else if (node->info.data.elem_type !=ICE_AQC_ELEM_TYPE_LEAF && node->parent->rate_node) { rate_node = devl_rate_node_create(devlink, node, node->name,
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +2 -1
@@ -732,7 +732,8 @@ int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port)*/ void ice_devlink_destroy_sf_port (struct ice_dynamic_port *dyn_port) { -devl_port_unregister (&dyn_port->devlink_port); +devl_rate_leaf_destroy (&dyn_port->devlink_port); +devl_port_unregister (&dyn_port->devlink_port); }/**
drivers/net/ethernet/intel/ice/ice_repr.c +7 -5
@@ -347,16 +347,13 @@ static void ice_repr_rem_sf(struct ice_repr *repr)ice_devlink_destroy_sf_port (repr->sf); } -static void ice_repr_set_tx_topology (struct ice_pf *pf) +static void ice_repr_set_tx_topology (struct ice_pf *pf,struct devlink *devlink) { -struct devlink *devlink; -/* only export if ADQ and DCB disabled and eswitch enabled*/ if (ice_is_adq_active (pf) ||ice_is_dcb_active (pf) || !ice_is_switchdev_running (pf))return ; - devlink =priv_to_devlink (pf);ice_devlink_rate_init_tx_topology (devlink,ice_get_main_vsi (pf)); }
@@ -408,6 +405,7 @@ static struct ice_repr *ice_repr_create(struct ice_vsi *src_vsi)static int ice_repr_add_vf (struct ice_repr *repr) {struct ice_vf *vf = repr->vf; +struct devlink *devlink;int err; err =ice_devlink_create_vf_port (vf);
@@ -424,7 +422,9 @@ static int ice_repr_add_vf(struct ice_repr *repr) goto err_cfg_vsi;ice_virtchnl_set_repr_ops (vf); -ice_repr_set_tx_topology (vf->pf); + + devlink =priv_to_devlink (vf->pf); +ice_repr_set_tx_topology (vf->pf, devlink);return 0 ;
@@ -472,6 +472,8 @@ static int ice_repr_add_sf(struct ice_repr *repr)if (err) goto err_netdev; +ice_repr_set_tx_topology (sf->vsi->back,priv_to_devlink (sf->vsi->back)); +return 0 ; err_netdev:
Signature · 1 line
2.42.0
PATCH 13/14 ice: basic support for VLAN in subfunctions
In reply to Michal SwiatkowskiImplement add / delete vlan for subfunction type VSI.
--- drivers/net/ethernet/intel/ice/Makefile | 1 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 +++++++++++++++++++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 ++++++++++++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 ++++ 4 files changed, 39 insertions(+) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -32,6 +32,7 @@ ice-y := ice_main.o \ devlink/devlink.o \ devlink/devlink_port.o \ ice_sf_eth.o \ + ice_sf_vsi_vlan_ops.o \ ice_ddp.o \ ice_fw_update.o \ ice_lag.o \
drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2023, Intel Corporation. */ + +#include "ice_vsi_vlan_ops.h" +#include "ice_vsi_vlan_lib.h" +#include "ice_vlan_mode.h" +#include "ice.h" +#include "ice_sf_vsi_vlan_ops.h" + +void ice_sf_vsi_init_vlan_ops (struct ice_vsi *vsi) +{ +struct ice_vsi_vlan_ops *vlan_ops; + +if (ice_is_dvm_ena (&vsi->back->hw)) + vlan_ops = &vsi->outer_vlan_ops; +else + vlan_ops = &vsi->inner_vlan_ops; + + vlan_ops->add_vlan = ice_vsi_add_vlan; + vlan_ops->del_vlan = ice_vsi_del_vlan; +}
drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2023, Intel Corporation. */ + +#ifndef _ICE_SF_VSI_VLAN_OPS_H_ +#define _ICE_SF_VSI_VLAN_OPS_H_ + +#include "ice_vsi_vlan_ops.h" + +struct ice_vsi ; + +void ice_sf_vsi_init_vlan_ops (struct ice_vsi *vsi); + +#endif /* _ICE_SF_VSI_VLAN_OPS_H_ */
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c +4 -0
@@ -3,6 +3,7 @@#include "ice_pf_vsi_vlan_ops.h" #include "ice_vf_vsi_vlan_ops.h" +#include "ice_sf_vsi_vlan_ops.h" #include "ice_lib.h" #include "ice.h"
@@ -77,6 +78,9 @@ void ice_vsi_init_vlan_ops(struct ice_vsi *vsi)case ICE_VSI_VF :ice_vf_vsi_init_vlan_ops (vsi);break ; +case ICE_VSI_SF : +ice_sf_vsi_init_vlan_ops (vsi); +break ;default :dev_dbg (ice_pf_to_dev (vsi->back),"%s does not support VLAN operations\n" ,ice_vsi_type_str (vsi->type));
Signature · 1 line
2.42.0
PATCH 14/14 ice: allow to activate and deactivate subfunction
In reply to Michal SwiatkowskiFrom: Piotr Raczynski <[email protected]>
Use previously implemented SF aux driver. It is probe during SF activation and remove after deactivation.
--- .../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 6 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 107 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 3 + 4 files changed, 224 insertions(+)
drivers/net/ethernet/intel/ice/devlink/devlink_port.c +108 -0
@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)devl_port_unregister (&sf_dev->priv->devlink_port); } +/** +* ice_activate_dynamic_port - Activate a dynamic port +* @dyn_port: dynamic port instance to activate +* @extack: extack for reporting error messages +* +* Activate the dynamic port based on its flavour. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_activate_dynamic_port (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +int err; + + err =ice_sf_eth_activate (dyn_port, extack); +if (err) +return err; + + dyn_port->active = true; + +return 0 ; +} + +/** +* ice_deactivate_dynamic_port - Deactivate a dynamic port +* @dyn_port: dynamic port instance to deactivate +* +* Undo activation of a dynamic port. +*/ +static void ice_deactivate_dynamic_port (struct ice_dynamic_port *dyn_port) +{ +ice_sf_eth_deactivate (dyn_port); + dyn_port->active = false; +} +/** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate
@@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)struct devlink_port *devlink_port = &dyn_port->devlink_port;struct ice_pf *pf = dyn_port->pf; +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf);ice_eswitch_detach_sf (pf, dyn_port);ice_vsi_free (dyn_port->vsi);
@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,return 0 ; } +/** +* ice_devlink_port_fn_state_set - devlink handler for port state set +* @port: pointer to devlink port +* @state: state to set +* @extack: extack for reporting error messages +* +* Activates or deactivates the port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_set (struct devlink_port *port, +enum devlink_port_fn_state state, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +switch (state) { +case DEVLINK_PORT_FN_STATE_ACTIVE : +if (!dyn_port->active) +return ice_activate_dynamic_port (dyn_port, extack); +break ; +case DEVLINK_PORT_FN_STATE_INACTIVE : +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +break ; + } + +return 0 ; +} + +/** +* ice_devlink_port_fn_state_get - devlink handler for port state get +* @port: pointer to devlink port +* @state: admin configured state of the port +* @opstate: current port operational state +* @extack: extack for reporting error messages +* +* Gets port state. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_get (struct devlink_port *port, +enum devlink_port_fn_state *state, +enum devlink_port_fn_opstate *opstate, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (dyn_port->active) + *state =DEVLINK_PORT_FN_STATE_ACTIVE ; +else + *state =DEVLINK_PORT_FN_STATE_INACTIVE ; + +if (dyn_port->attached) + *opstate =DEVLINK_PORT_FN_OPSTATE_ATTACHED ; +else + *opstate =DEVLINK_PORT_FN_OPSTATE_DETACHED ; + +return 0 ; +} +static const struct devlink_port_ops ice_devlink_port_sf_ops = { .port_del = ice_devlink_port_del, .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, + .port_fn_state_get = ice_devlink_port_fn_state_get, + .port_fn_state_set = ice_devlink_port_fn_state_set, };/**
drivers/net/ethernet/intel/ice/devlink/devlink_port.h +6 -0
@@ -14,17 +14,23 @@* @devlink_port: the associated devlink port structure * @pf: pointer to the PF private structure * @vsi: the VSI associated with this port +* @sf_dev: pointer to the subfunction device * * An instance of a dynamically added devlink port. Each port flavour */ struct ice_dynamic_port {u8 hw_addr[ETH_ALEN ];u8 active:1 ; +u8 attached:1 ;struct devlink_port devlink_port;struct ice_pf *pf;struct ice_vsi *vsi;unsigned long repr_id;u32 sfnum; +/* Flavour-specific implementation data */ +union { +struct ice_sf_dev *sf_dev; + }; };void ice_dealloc_all_dynamic_ports (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_sf_eth.c +107 -0
128 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sf_eth.h +3 -0
@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)int ice_sf_driver_register (void );void ice_sf_driver_unregister (void ); +int ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack); +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port);#endif /* _ICE_SF_ETH_H_ */
Signature · 1 line
2.42.0
Re: [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction
Quoted 241 lines · Tue, May 07, 2024 at 01:45:15PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Use previously implemented SF aux driver. It is probe during SF activation and remove after deactivation.
Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 6 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 107 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 3 + 4 files changed, 224 insertions(+)drivers/net/ethernet/intel/ice/devlink/devlink_port.c +108
-0@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)devl_port_unregister (&sf_dev->priv->devlink_port); } +/** +* ice_activate_dynamic_port - Activate a dynamic port +* @dyn_port: dynamic port instance to activate +* @extack: extack for reporting error messages +* +* Activate the dynamic port based on its flavour. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_activate_dynamic_port (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +int err; + + err =ice_sf_eth_activate (dyn_port, extack); +if (err) +return err; + + dyn_port->active = true; + +return 0 ; +} + +/** +* ice_deactivate_dynamic_port - Deactivate a dynamic port +* @dyn_port: dynamic port instance to deactivate +* +* Undo activation of a dynamic port. +*/ +static void ice_deactivate_dynamic_port (struct ice_dynamic_port *dyn_port) +{ +ice_sf_eth_deactivate (dyn_port); + dyn_port->active = false; +} +/** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate @@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)struct devlink_port *devlink_port = &dyn_port->devlink_port;struct ice_pf *pf = dyn_port->pf; +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf);ice_eswitch_detach_sf (pf, dyn_port);ice_vsi_free (dyn_port->vsi);@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,return 0 ; } +/** +* ice_devlink_port_fn_state_set - devlink handler for port state set +* @port: pointer to devlink port +* @state: state to set +* @extack: extack for reporting error messages +* +* Activates or deactivates the port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_set (struct devlink_port *port, +enum devlink_port_fn_state state, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +switch (state) { +case DEVLINK_PORT_FN_STATE_ACTIVE : +if (!dyn_port->active) +return ice_activate_dynamic_port (dyn_port, extack); +break ; +case DEVLINK_PORT_FN_STATE_INACTIVE : +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +break ; + } + +return 0 ; +} + +/** +* ice_devlink_port_fn_state_get - devlink handler for port state get +* @port: pointer to devlink port +* @state: admin configured state of the port +* @opstate: current port operational state +* @extack: extack for reporting error messages +* +* Gets port state. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_get (struct devlink_port *port, +enum devlink_port_fn_state *state, +enum devlink_port_fn_opstate *opstate, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (dyn_port->active) + *state =DEVLINK_PORT_FN_STATE_ACTIVE ; +else + *state =DEVLINK_PORT_FN_STATE_INACTIVE ; + +if (dyn_port->attached) + *opstate =DEVLINK_PORT_FN_OPSTATE_ATTACHED ; +else + *opstate =DEVLINK_PORT_FN_OPSTATE_DETACHED ; + +return 0 ; +} +static const struct devlink_port_ops ice_devlink_port_sf_ops = { .port_del = ice_devlink_port_del, .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, + .port_fn_state_get = ice_devlink_port_fn_state_get, + .port_fn_state_set = ice_devlink_port_fn_state_set, };/** drivers/net/ethernet/intel/ice/devlink/devlink_port.h +6
-0@@ -14,17 +14,23 @@* @devlink_port: the associated devlink port structure * @pf: pointer to the PF private structure * @vsi: the VSI associated with this port +* @sf_dev: pointer to the subfunction device * * An instance of a dynamically added devlink port. Each port flavour */ struct ice_dynamic_port {u8 hw_addr[ETH_ALEN ];u8 active:1 ; +u8 attached:1 ;struct devlink_port devlink_port;struct ice_pf *pf;struct ice_vsi *vsi;unsigned long repr_id;u32 sfnum; +/* Flavour-specific implementation data */ +union { +struct ice_sf_dev *sf_dev; + }; };void ice_dealloc_all_dynamic_ports (struct ice_pf *pf);drivers/net/ethernet/intel/ice/ice_sf_eth.c +33
-0@@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,devl_unlock (devlink);devlink_register (devlink); + dyn_port->attached = true;return 0 ;@@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)devl_unlock (devlink);devlink_free (devlink);ice_vsi_decfg (vsi); + + dyn_port->attached = false; }static const struct auxiliary_device_id ice_sf_dev_id_table[] = {@@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = { .id_table = ice_sf_dev_id_table }; +static DEFINE_XARRAY_ALLOC1 (ice_sf_aux_id); +/** * ice_sf_driver_register - Register new auxiliary subfunction driver * @@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void) {auxiliary_driver_unregister (&ice_sf_driver); } + +/** +* ice_sf_dev_release - Release device associated with auxiliary device +* @device: pointer to the device +* +* Since most of the code for subfunction deactivation is handled in +* the remove handler, here just free tracking resources. +*/ +static void ice_sf_dev_release (struct device *device) +{ +struct auxiliary_device *adev =to_auxiliary_dev (device); +struct ice_sf_dev *sf_dev =ice_adev_to_sf_dev (adev); + +xa_erase (&ice_sf_aux_id, adev->id); +kfree (sf_dev); +} + +/** +* ice_sf_eth_activate - Activate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* @extack: extack for reporting error messages +* +* Activate the dynamic port as an Ethernet subfunction. Setup the netdev +* resources associated and initialize the auxiliary device. +* +* Return: zero on success or an error code on failure. +*/ +int
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 265
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +10
-0+ice_sf_eth_activate(struct ice_dynamic_port *dyn_port, + struct netlink_ext_ack *extack) +{ + struct ice_pf *pf = dyn_port->pf; +struct ice_sf_dev *sf_dev; +struct pci_dev *pdev; +int err; +u32 id; + + err = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b,
Double space.
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +19
-0+ GFP_KERNEL); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Could not allocate subfunction ID" ); +return err; + } + + sf_dev =kzalloc (sizeof (*sf_dev),GFP_KERNEL ); +if (!sf_dev) { + err = -ENOMEM ; +NL_SET_ERR_MSG_MOD (extack,"Could not allocate sf_dev memory" ); + goto xa_erase; + } + pdev = pf->pdev; + + sf_dev->dyn_port = dyn_port; + sf_dev->adev.id = id; + sf_dev->adev.name ="sf" ; + sf_dev->adev.dev.release = ice_sf_dev_release; + sf_dev->adev.dev.parent = &pdev->dev;
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 294
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +10
-0+ + err =auxiliary_device_init (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to initialize auxiliary device" ); + goto sf_dev_free; + } + + err =auxiliary_device_add (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Auxiliary device failed to probe" );
How do you know? Probe may happen async.
Quoted 51 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +35
-0+ goto aux_dev_uninit; + } + + dyn_port->sf_dev = sf_dev; + +return 0 ; + +aux_dev_uninit: +auxiliary_device_uninit (&sf_dev->adev); +sf_dev_free: +kfree (sf_dev); +xa_erase: +xa_erase (&ice_sf_aux_id, id); + +return err; +} + +/** +* ice_sf_eth_deactivate - Deactivate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* +* Deactivate the Ethernet subfunction, removing its auxiliary device and the +* associated resources. +*/ +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port) +{ +struct ice_sf_dev *sf_dev = dyn_port->sf_dev; + +if (sf_dev) { +auxiliary_device_delete (&sf_dev->adev); +auxiliary_device_uninit (&sf_dev->adev); + } + + dyn_port->sf_dev =NULL ; +}drivers/net/ethernet/intel/ice/ice_sf_eth.h +3
-0@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)int ice_sf_driver_register (void );void ice_sf_driver_unregister (void ); +int ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack); +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port);#endif /* _ICE_SF_ETH_H_ */ Signature · 1 line
2.42.0
Re: [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction
Quoted 246 lines · Jiri Pirko
Quoted 245 lines · Tue, May 07, 2024 at 01:45:15PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Use previously implemented SF aux driver. It is probe during SF activation and remove after deactivation.
Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 6 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 107 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 3 + 4 files changed, 224 insertions(+)drivers/net/ethernet/intel/ice/devlink/devlink_port.c +108
-0@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)devl_port_unregister (&sf_dev->priv->devlink_port); } +/** +* ice_activate_dynamic_port - Activate a dynamic port +* @dyn_port: dynamic port instance to activate +* @extack: extack for reporting error messages +* +* Activate the dynamic port based on its flavour. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_activate_dynamic_port (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +int err; + + err =ice_sf_eth_activate (dyn_port, extack); +if (err) +return err; + + dyn_port->active = true; + +return 0 ; +} + +/** +* ice_deactivate_dynamic_port - Deactivate a dynamic port +* @dyn_port: dynamic port instance to deactivate +* +* Undo activation of a dynamic port. +*/ +static void ice_deactivate_dynamic_port (struct ice_dynamic_port *dyn_port) +{ +ice_sf_eth_deactivate (dyn_port); + dyn_port->active = false; +} +/** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate @@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)struct devlink_port *devlink_port = &dyn_port->devlink_port;struct ice_pf *pf = dyn_port->pf; +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf);ice_eswitch_detach_sf (pf, dyn_port);ice_vsi_free (dyn_port->vsi);@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,return 0 ; } +/** +* ice_devlink_port_fn_state_set - devlink handler for port state set +* @port: pointer to devlink port +* @state: state to set +* @extack: extack for reporting error messages +* +* Activates or deactivates the port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_set (struct devlink_port *port, +enum devlink_port_fn_state state, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +switch (state) { +case DEVLINK_PORT_FN_STATE_ACTIVE : +if (!dyn_port->active) +return ice_activate_dynamic_port (dyn_port, extack); +break ; +case DEVLINK_PORT_FN_STATE_INACTIVE : +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +break ; + } + +return 0 ; +} + +/** +* ice_devlink_port_fn_state_get - devlink handler for port state get +* @port: pointer to devlink port +* @state: admin configured state of the port +* @opstate: current port operational state +* @extack: extack for reporting error messages +* +* Gets port state. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_get (struct devlink_port *port, +enum devlink_port_fn_state *state, +enum devlink_port_fn_opstate *opstate, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (dyn_port->active) + *state =DEVLINK_PORT_FN_STATE_ACTIVE ; +else + *state =DEVLINK_PORT_FN_STATE_INACTIVE ; + +if (dyn_port->attached) + *opstate =DEVLINK_PORT_FN_OPSTATE_ATTACHED ; +else + *opstate =DEVLINK_PORT_FN_OPSTATE_DETACHED ; + +return 0 ; +} +static const struct devlink_port_ops ice_devlink_port_sf_ops = { .port_del = ice_devlink_port_del, .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, + .port_fn_state_get = ice_devlink_port_fn_state_get, + .port_fn_state_set = ice_devlink_port_fn_state_set, };/** drivers/net/ethernet/intel/ice/devlink/devlink_port.h +6
-0@@ -14,17 +14,23 @@* @devlink_port: the associated devlink port structure * @pf: pointer to the PF private structure * @vsi: the VSI associated with this port +* @sf_dev: pointer to the subfunction device * * An instance of a dynamically added devlink port. Each port flavour */ struct ice_dynamic_port {u8 hw_addr[ETH_ALEN ];u8 active:1 ; +u8 attached:1 ;struct devlink_port devlink_port;struct ice_pf *pf;struct ice_vsi *vsi;unsigned long repr_id;u32 sfnum; +/* Flavour-specific implementation data */ +union { +struct ice_sf_dev *sf_dev; + }; };void ice_dealloc_all_dynamic_ports (struct ice_pf *pf);drivers/net/ethernet/intel/ice/ice_sf_eth.c +37
-0@@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,devl_unlock (devlink);devlink_register (devlink); + dyn_port->attached = true;return 0 ;@@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)devl_unlock (devlink);devlink_free (devlink);ice_vsi_decfg (vsi); + + dyn_port->attached = false; }static const struct auxiliary_device_id ice_sf_dev_id_table[] = {@@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = { .id_table = ice_sf_dev_id_table }; +static DEFINE_XARRAY_ALLOC1 (ice_sf_aux_id); +/** * ice_sf_driver_register - Register new auxiliary subfunction driver * @@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void) {auxiliary_driver_unregister (&ice_sf_driver); } + +/** +* ice_sf_dev_release - Release device associated with auxiliary device +* @device: pointer to the device +* +* Since most of the code for subfunction deactivation is handled in +* the remove handler, here just free tracking resources. +*/ +static void ice_sf_dev_release (struct device *device) +{ +struct auxiliary_device *adev =to_auxiliary_dev (device); +struct ice_sf_dev *sf_dev =ice_adev_to_sf_dev (adev); + +xa_erase (&ice_sf_aux_id, adev->id); +kfree (sf_dev); +} + +/** +* ice_sf_eth_activate - Activate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* @extack: extack for reporting error messages +* +* Activate the dynamic port as an Ethernet subfunction. Setup the netdev +* resources associated and initialize the auxiliary device. +* +* Return: zero on success or an error code on failure. +*/ +int +ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +struct ice_pf *pf = dyn_port->pf;
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 265
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +6
-0+struct ice_sf_dev *sf_dev; +struct pci_dev *pdev; +int err; +u32 id; + + err = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b,Double space.
Thanks, will fix.
Quoted 24 lines
Quoted 24 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +23
-0+ GFP_KERNEL); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Could not allocate subfunction ID" ); +return err; + } + + sf_dev =kzalloc (sizeof (*sf_dev),GFP_KERNEL ); +if (!sf_dev) { + err = -ENOMEM ; +NL_SET_ERR_MSG_MOD (extack,"Could not allocate sf_dev memory" ); + goto xa_erase; + } + pdev = pf->pdev; + + sf_dev->dyn_port = dyn_port; + sf_dev->adev.id = id; + sf_dev->adev.name ="sf" ; + sf_dev->adev.dev.release = ice_sf_dev_release; + sf_dev->adev.dev.parent = &pdev->dev; + + err =auxiliary_device_init (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to initialize auxiliary device" );
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 294
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +6
-0+ goto sf_dev_free; + } + + err =auxiliary_device_add (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Auxiliary device failed to probe" );How do you know? Probe may happen async.
"Failed to add SF aux device" will be fine?
Quoted 52 lines
Quoted 52 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +35
-0+ goto aux_dev_uninit; + } + + dyn_port->sf_dev = sf_dev; + +return 0 ; + +aux_dev_uninit: +auxiliary_device_uninit (&sf_dev->adev); +sf_dev_free: +kfree (sf_dev); +xa_erase: +xa_erase (&ice_sf_aux_id, id); + +return err; +} + +/** +* ice_sf_eth_deactivate - Deactivate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* +* Deactivate the Ethernet subfunction, removing its auxiliary device and the +* associated resources. +*/ +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port) +{ +struct ice_sf_dev *sf_dev = dyn_port->sf_dev; + +if (sf_dev) { +auxiliary_device_delete (&sf_dev->adev); +auxiliary_device_uninit (&sf_dev->adev); + } + + dyn_port->sf_dev =NULL ; +}drivers/net/ethernet/intel/ice/ice_sf_eth.h +3
-0@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)int ice_sf_driver_register (void );void ice_sf_driver_unregister (void ); +int ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack); +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port);#endif /* _ICE_SF_ETH_H_ */ Signature · 1 line
2.42.0
Re: [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction
Quoted 293 lines · Fri, May 10, 2024 at 09:33:54AM CEST, [email protected] wrote:
Quoted 246 lines · Jiri Pirko
Quoted 245 lines · Tue, May 07, 2024 at 01:45:15PM CEST, [email protected] wrote:
From: Piotr Raczynski <[email protected]>
Use previously implemented SF aux driver. It is probe during SF activation and remove after deactivation.
Signed-off-by Piotr Raczynski <[email protected]>Signed-off-by Michal Swiatkowski <[email protected]>---
.../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 6 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 107 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 3 + 4 files changed, 224 insertions(+)drivers/net/ethernet/intel/ice/devlink/devlink_port.c +108
-0@@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev)devl_port_unregister (&sf_dev->priv->devlink_port); } +/** +* ice_activate_dynamic_port - Activate a dynamic port +* @dyn_port: dynamic port instance to activate +* @extack: extack for reporting error messages +* +* Activate the dynamic port based on its flavour. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_activate_dynamic_port (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +int err; + + err =ice_sf_eth_activate (dyn_port, extack); +if (err) +return err; + + dyn_port->active = true; + +return 0 ; +} + +/** +* ice_deactivate_dynamic_port - Deactivate a dynamic port +* @dyn_port: dynamic port instance to deactivate +* +* Undo activation of a dynamic port. +*/ +static void ice_deactivate_dynamic_port (struct ice_dynamic_port *dyn_port) +{ +ice_sf_eth_deactivate (dyn_port); + dyn_port->active = false; +} +/** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate @@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)struct devlink_port *devlink_port = &dyn_port->devlink_port;struct ice_pf *pf = dyn_port->pf; +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +xa_erase (&pf->sf_nums, devlink_port->attrs.pci_sf.sf);ice_eswitch_detach_sf (pf, dyn_port);ice_vsi_free (dyn_port->vsi);@@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr,return 0 ; } +/** +* ice_devlink_port_fn_state_set - devlink handler for port state set +* @port: pointer to devlink port +* @state: state to set +* @extack: extack for reporting error messages +* +* Activates or deactivates the port. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_set (struct devlink_port *port, +enum devlink_port_fn_state state, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +switch (state) { +case DEVLINK_PORT_FN_STATE_ACTIVE : +if (!dyn_port->active) +return ice_activate_dynamic_port (dyn_port, extack); +break ; +case DEVLINK_PORT_FN_STATE_INACTIVE : +if (dyn_port->active) +ice_deactivate_dynamic_port (dyn_port); +break ; + } + +return 0 ; +} + +/** +* ice_devlink_port_fn_state_get - devlink handler for port state get +* @port: pointer to devlink port +* @state: admin configured state of the port +* @opstate: current port operational state +* @extack: extack for reporting error messages +* +* Gets port state. +* +* Return: zero on success or an error code on failure. +*/ +static int +ice_devlink_port_fn_state_get (struct devlink_port *port, +enum devlink_port_fn_state *state, +enum devlink_port_fn_opstate *opstate, +struct netlink_ext_ack *extack) +{ +struct ice_dynamic_port *dyn_port; + + dyn_port =ice_devlink_port_to_dyn (port); + +if (dyn_port->active) + *state =DEVLINK_PORT_FN_STATE_ACTIVE ; +else + *state =DEVLINK_PORT_FN_STATE_INACTIVE ; + +if (dyn_port->attached) + *opstate =DEVLINK_PORT_FN_OPSTATE_ATTACHED ; +else + *opstate =DEVLINK_PORT_FN_OPSTATE_DETACHED ; + +return 0 ; +} +static const struct devlink_port_ops ice_devlink_port_sf_ops = { .port_del = ice_devlink_port_del, .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, + .port_fn_state_get = ice_devlink_port_fn_state_get, + .port_fn_state_set = ice_devlink_port_fn_state_set, };/** drivers/net/ethernet/intel/ice/devlink/devlink_port.h +6
-0@@ -14,17 +14,23 @@* @devlink_port: the associated devlink port structure * @pf: pointer to the PF private structure * @vsi: the VSI associated with this port +* @sf_dev: pointer to the subfunction device * * An instance of a dynamically added devlink port. Each port flavour */ struct ice_dynamic_port {u8 hw_addr[ETH_ALEN ];u8 active:1 ; +u8 attached:1 ;struct devlink_port devlink_port;struct ice_pf *pf;struct ice_vsi *vsi;unsigned long repr_id;u32 sfnum; +/* Flavour-specific implementation data */ +union { +struct ice_sf_dev *sf_dev; + }; };void ice_dealloc_all_dynamic_ports (struct ice_pf *pf);drivers/net/ethernet/intel/ice/ice_sf_eth.c +37
-0@@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev,devl_unlock (devlink);devlink_register (devlink); + dyn_port->attached = true;return 0 ;@@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev)devl_unlock (devlink);devlink_free (devlink);ice_vsi_decfg (vsi); + + dyn_port->attached = false; }static const struct auxiliary_device_id ice_sf_dev_id_table[] = {@@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = { .id_table = ice_sf_dev_id_table }; +static DEFINE_XARRAY_ALLOC1 (ice_sf_aux_id); +/** * ice_sf_driver_register - Register new auxiliary subfunction driver * @@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void) {auxiliary_driver_unregister (&ice_sf_driver); } + +/** +* ice_sf_dev_release - Release device associated with auxiliary device +* @device: pointer to the device +* +* Since most of the code for subfunction deactivation is handled in +* the remove handler, here just free tracking resources. +*/ +static void ice_sf_dev_release (struct device *device) +{ +struct auxiliary_device *adev =to_auxiliary_dev (device); +struct ice_sf_dev *sf_dev =ice_adev_to_sf_dev (adev); + +xa_erase (&ice_sf_aux_id, adev->id); +kfree (sf_dev); +} + +/** +* ice_sf_eth_activate - Activate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* @extack: extack for reporting error messages +* +* Activate the dynamic port as an Ethernet subfunction. Setup the netdev +* resources associated and initialize the auxiliary device. +* +* Return: zero on success or an error code on failure. +*/ +int +ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack) +{ +struct ice_pf *pf = dyn_port->pf;Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 265
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +6
-0+struct ice_sf_dev *sf_dev; +struct pci_dev *pdev; +int err; +u32 id; + + err = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b,Double space.
Thanks, will fix.
Quoted 24 lines
Quoted 24 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +23
-0+ GFP_KERNEL); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Could not allocate subfunction ID" ); +return err; + } + + sf_dev =kzalloc (sizeof (*sf_dev),GFP_KERNEL ); +if (!sf_dev) { + err = -ENOMEM ; +NL_SET_ERR_MSG_MOD (extack,"Could not allocate sf_dev memory" ); + goto xa_erase; + } + pdev = pf->pdev; + + sf_dev->dyn_port = dyn_port; + sf_dev->adev.id = id; + sf_dev->adev.name ="sf" ; + sf_dev->adev.dev.release = ice_sf_dev_release; + sf_dev->adev.dev.parent = &pdev->dev; + + err =auxiliary_device_init (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to initialize auxiliary device" );Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c void ice_sf_driver_unregister(void) · line 294
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +6
-0+ goto sf_dev_free; + } + + err =auxiliary_device_add (&sf_dev->adev); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Auxiliary device failed to probe" );How do you know? Probe may happen async.
Quoted 1 line
"Failed to add SF aux device" will be fine?
Sure.
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +35
-0+ goto aux_dev_uninit; + } + + dyn_port->sf_dev = sf_dev; + +return 0 ; + +aux_dev_uninit: +auxiliary_device_uninit (&sf_dev->adev); +sf_dev_free: +kfree (sf_dev); +xa_erase: +xa_erase (&ice_sf_aux_id, id); + +return err; +} + +/** +* ice_sf_eth_deactivate - Deactivate Ethernet subfunction port +* @dyn_port: the dynamic port instance for this subfunction +* +* Deactivate the Ethernet subfunction, removing its auxiliary device and the +* associated resources. +*/ +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port) +{ +struct ice_sf_dev *sf_dev = dyn_port->sf_dev; + +if (sf_dev) { +auxiliary_device_delete (&sf_dev->adev); +auxiliary_device_uninit (&sf_dev->adev); + } + + dyn_port->sf_dev =NULL ; +}drivers/net/ethernet/intel/ice/ice_sf_eth.h +3
-0@@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev)int ice_sf_driver_register (void );void ice_sf_driver_unregister (void ); +int ice_sf_eth_activate (struct ice_dynamic_port *dyn_port, +struct netlink_ext_ack *extack); +void ice_sf_eth_deactivate (struct ice_dynamic_port *dyn_port);#endif /* _ICE_SF_ETH_H_ */ Signature · 1 line
2.42.0
Quoted 22 lines · Tue, May 07, 2024 at 01:45:01PM CEST, [email protected] wrote:
Hi,
Currently ice driver does not allow creating more than one networking device per physical function. The only way to have more hardware backed netdev is to use SR-IOV.
Following patchset adds support for devlink port API. For each new pcisf type port, driver allocates new VSI, configures all resources needed, including dynamically MSIX vectors, program rules and registers new netdev.
This series supports only one Tx/Rx queue pair per subfunction.
Example commands:
devlink port add pci/0000:31:00.1 flavour pcisf pfnum 1 sfnum 1000 devlink port function set pci/0000:31:00.1/1hw_addr00:00:00:00:03:14 devlink port function set pci/0000:31:00.1/1 state active devlink port function del pci/0000:31:00.1/1Make the port representor and eswitch code generic to support subfunction representor type.
Quoted 8 lines
VSI configuration is slightly different between VF and SF. It needs to be reflected in the code.
Most recent previous patchset (not containing port representor for SF support). [1]
I don't understand howcome the patchset is v1, yet there are patches that came through multiple iterations alread. Changelog is missing completely :/
Quoted 54 lines
Michal Swiatkowski (7):
ice: treat subfunction VSI the same as PF VSI
ice: create port representor for SF
ice: don't set target VSI for subfunction
ice: check if SF is ready in ethtool ops
ice: netdevice ops for SF representor
ice: support subfunction devlink Tx topology
ice: basic support for VLAN in subfunctionsPiotr Raczynski (7):
ice: add new VSI type for subfunctions
ice: export icendo_opsfunctions
ice: add basic devlink subfunctions support
ice: allocate devlink for subfunction
ice: base subfunction aux driver
ice: implement netdev for subfunction
ice: allow to activate and deactivate subfunctiondrivers/net/ethernet/intel/ice/Makefile | 2 + .../net/ethernet/intel/ice/devlink/devlink.c | 48 ++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 516 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 43 ++ drivers/net/ethernet/intel/ice/ice.h | 19 +- drivers/net/ethernet/intel/ice/ice_base.c | 5 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 ++- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +- drivers/net/ethernet/intel/ice/ice_lib.c | 52 +- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 66 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 22 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 329 +++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 33 ++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 26 files changed, 1362 insertions(+), 138 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_sf_eth.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_eth.hcreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.hSignature · 1 line
2.42.0
Quoted 29 lines · Jiri Pirko
Quoted 28 lines · Tue, May 07, 2024 at 01:45:01PM CEST, [email protected] wrote:
Hi,
Currently ice driver does not allow creating more than one networking device per physical function. The only way to have more hardware backed netdev is to use SR-IOV.
Following patchset adds support for devlink port API. For each new pcisf type port, driver allocates new VSI, configures all resources needed, including dynamically MSIX vectors, program rules and registers new netdev.
This series supports only one Tx/Rx queue pair per subfunction.
Example commands:
devlink port add pci/0000:31:00.1 flavour pcisf pfnum 1 sfnum 1000 devlink port function set pci/0000:31:00.1/1hw_addr00:00:00:00:03:14 devlink port function set pci/0000:31:00.1/1 state active devlink port function del pci/0000:31:00.1/1Make the port representor and eswitch code generic to support subfunction representor type.
VSI configuration is slightly different between VF and SF. It needs to be reflected in the code.
Most recent previous patchset (not containing port representor for SF support). [1]
Quoted 8 lines
Quoted 2 lines
I don't understand howcome the patchset is v1, yet there are patches that came through multiple iterations alread. Changelog is missing completely :/
What is wrong here? There is a link to previous patchset with whole changlog and links to previous ones. I didn't add changlog here as it is new patchset (partialy the same as from [1], because of that I added a link). I can add the changlog from [1] if you want, but for me it can be missleading.
Quoted 55 lines
Quoted 55 lines
Michal Swiatkowski (7):
ice: treat subfunction VSI the same as PF VSI
ice: create port representor for SF
ice: don't set target VSI for subfunction
ice: check if SF is ready in ethtool ops
ice: netdevice ops for SF representor
ice: support subfunction devlink Tx topology
ice: basic support for VLAN in subfunctionsPiotr Raczynski (7):
ice: add new VSI type for subfunctions
ice: export icendo_opsfunctions
ice: add basic devlink subfunctions support
ice: allocate devlink for subfunction
ice: base subfunction aux driver
ice: implement netdev for subfunction
ice: allow to activate and deactivate subfunctiondrivers/net/ethernet/intel/ice/Makefile | 2 + .../net/ethernet/intel/ice/devlink/devlink.c | 48 ++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 516 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 43 ++ drivers/net/ethernet/intel/ice/ice.h | 19 +- drivers/net/ethernet/intel/ice/ice_base.c | 5 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 ++- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +- drivers/net/ethernet/intel/ice/ice_lib.c | 52 +- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 66 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 22 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 329 +++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 33 ++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 26 files changed, 1362 insertions(+), 138 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_sf_eth.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_eth.hcreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.hSignature · 1 line
2.42.0
Quoted 39 lines · Fri, May 10, 2024 at 09:24:48AM CEST, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Quoted 28 lines · Tue, May 07, 2024 at 01:45:01PM CEST, [email protected] wrote:
Hi,
Currently ice driver does not allow creating more than one networking device per physical function. The only way to have more hardware backed netdev is to use SR-IOV.
Following patchset adds support for devlink port API. For each new pcisf type port, driver allocates new VSI, configures all resources needed, including dynamically MSIX vectors, program rules and registers new netdev.
This series supports only one Tx/Rx queue pair per subfunction.
Example commands:
devlink port add pci/0000:31:00.1 flavour pcisf pfnum 1 sfnum 1000 devlink port function set pci/0000:31:00.1/1hw_addr00:00:00:00:03:14 devlink port function set pci/0000:31:00.1/1 state active devlink port function del pci/0000:31:00.1/1Make the port representor and eswitch code generic to support subfunction representor type.
VSI configuration is slightly different between VF and SF. It needs to be reflected in the code.
Most recent previous patchset (not containing port representor for SF support). [1]
Quoted 8 lines
Quoted 2 lines
I don't understand howcome the patchset is v1, yet there are patches that came through multiple iterations alread. Changelog is missing completely :/
Quoted 5 lines
What is wrong here? There is a link to previous patchset with whole changlog and links to previous ones. I didn't add changlog here as it is new patchset (partialy the same as from [1], because of that I added a link). I can add the changlog from [1] if you want, but for me it can be missleading.
It's always good to see what you changed if you send modified patches. That's all.
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Michal Swiatkowski (7):
ice: treat subfunction VSI the same as PF VSI
ice: create port representor for SF
ice: don't set target VSI for subfunction
ice: check if SF is ready in ethtool ops
ice: netdevice ops for SF representor
ice: support subfunction devlink Tx topology
ice: basic support for VLAN in subfunctionsPiotr Raczynski (7):
ice: add new VSI type for subfunctions
ice: export icendo_opsfunctions
ice: add basic devlink subfunctions support
ice: allocate devlink for subfunction
ice: base subfunction aux driver
ice: implement netdev for subfunction
ice: allow to activate and deactivate subfunctiondrivers/net/ethernet/intel/ice/Makefile | 2 + .../net/ethernet/intel/ice/devlink/devlink.c | 48 ++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 516 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 43 ++ drivers/net/ethernet/intel/ice/ice.h | 19 +- drivers/net/ethernet/intel/ice/ice_base.c | 5 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 ++- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +- drivers/net/ethernet/intel/ice/ice_lib.c | 52 +- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 66 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 22 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 329 +++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 33 ++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 26 files changed, 1362 insertions(+), 138 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_sf_eth.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_eth.hcreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.hSignature · 1 line
2.42.0
Quoted 40 lines · Jiri Pirko
Quoted 39 lines · Fri, May 10, 2024 at 09:24:48AM CEST, [email protected] wrote:
Quoted 37 lines · Jiri Pirko
Quoted 22 lines · Tue, May 07, 2024 at 01:45:01PM CEST, [email protected] wrote:
Hi,
Currently ice driver does not allow creating more than one networking device per physical function. The only way to have more hardware backed netdev is to use SR-IOV.
Following patchset adds support for devlink port API. For each new pcisf type port, driver allocates new VSI, configures all resources needed, including dynamically MSIX vectors, program rules and registers new netdev.
This series supports only one Tx/Rx queue pair per subfunction.
Example commands:
devlink port add pci/0000:31:00.1 flavour pcisf pfnum 1 sfnum 1000 devlink port function set pci/0000:31:00.1/1hw_addr00:00:00:00:03:14 devlink port function set pci/0000:31:00.1/1 state active devlink port function del pci/0000:31:00.1/1Make the port representor and eswitch code generic to support subfunction representor type.
Quoted 8 lines
VSI configuration is slightly different between VF and SF. It needs to be reflected in the code.
Most recent previous patchset (not containing port representor for SF support). [1]
I don't understand howcome the patchset is v1, yet there are patches that came through multiple iterations alread. Changelog is missing completely :/
Quoted 9 lines
Quoted 5 lines
What is wrong here? There is a link to previous patchset with whole changlog and links to previous ones. I didn't add changlog here as it is new patchset (partialy the same as from [1], because of that I added a link). I can add the changlog from [1] if you want, but for me it can be missleading.
It's always good to see what you changed if you send modified patches. That's all.
I will paste previous changelog in next version so.
Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Michal Swiatkowski (7):
ice: treat subfunction VSI the same as PF VSI
ice: create port representor for SF
ice: don't set target VSI for subfunction
ice: check if SF is ready in ethtool ops
ice: netdevice ops for SF representor
ice: support subfunction devlink Tx topology
ice: basic support for VLAN in subfunctionsPiotr Raczynski (7):
ice: add new VSI type for subfunctions
ice: export icendo_opsfunctions
ice: add basic devlink subfunctions support
ice: allocate devlink for subfunction
ice: base subfunction aux driver
ice: implement netdev for subfunction
ice: allow to activate and deactivate subfunctiondrivers/net/ethernet/intel/ice/Makefile | 2 + .../net/ethernet/intel/ice/devlink/devlink.c | 48 ++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 516 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 43 ++ drivers/net/ethernet/intel/ice/ice.h | 19 +- drivers/net/ethernet/intel/ice/ice_base.c | 5 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 ++- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +- drivers/net/ethernet/intel/ice/ice_lib.c | 52 +- drivers/net/ethernet/intel/ice/ice_lib.h | 3 + drivers/net/ethernet/intel/ice/ice_main.c | 66 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 22 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 329 +++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 33 ++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 + drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 26 files changed, 1362 insertions(+), 138 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_sf_eth.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_eth.hcreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.hSignature · 1 line
2.42.0