From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Cc: shayd@nvidia.com, wojciech.drewek@intel.com, horms@kernel.org,
sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com,
netdev@vger.kernel.org, jiri@nvidia.com,
kalesh-anakkur.purayil@broadcom.com, michal.kubiak@intel.com,
intel-wired-lan@lists.osuosl.org, pio.raczynski@gmail.com,
przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com
Subject: Re: [Intel-wired-lan] [iwl-next v5 07/15] ice: implement netdev for subfunction
Date: Thu, 27 Jun 2024 13:13:47 +0200 [thread overview]
Message-ID: <Zn1JaxkObIWjkVAZ@boxer> (raw)
In-Reply-To: <20240606112503.1939759-8-michal.swiatkowski@linux.intel.com>
On Thu, Jun 06, 2024 at 01:24:55PM +0200, Michal Swiatkowski wrote:
> From: Piotr Raczynski <piotr.raczynski@intel.com>
>
> 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.
>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_sf_eth.c | 85 ++++++++++++++++++++-
> 1 file changed, 84 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> index abe495c2d033..3a540a2638d1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> @@ -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;
please include:
netdev->xdp_zc_max_segs = ICE_MAX_BUF_TXD;
so that xsk ZC multi-buffer is also supported on SF netdevs.
> +
> + 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);
> --
> 2.42.0
>
WARNING: multiple messages have this Message-ID (diff)
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Cc: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
<jacob.e.keller@intel.com>, <michal.kubiak@intel.com>,
<sridhar.samudrala@intel.com>, <przemyslaw.kitszel@intel.com>,
<wojciech.drewek@intel.com>, <pio.raczynski@gmail.com>,
<jiri@nvidia.com>, <mateusz.polchlopek@intel.com>,
<shayd@nvidia.com>, <kalesh-anakkur.purayil@broadcom.com>,
<horms@kernel.org>
Subject: Re: [iwl-next v5 07/15] ice: implement netdev for subfunction
Date: Thu, 27 Jun 2024 13:13:47 +0200 [thread overview]
Message-ID: <Zn1JaxkObIWjkVAZ@boxer> (raw)
In-Reply-To: <20240606112503.1939759-8-michal.swiatkowski@linux.intel.com>
On Thu, Jun 06, 2024 at 01:24:55PM +0200, Michal Swiatkowski wrote:
> From: Piotr Raczynski <piotr.raczynski@intel.com>
>
> 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.
>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_sf_eth.c | 85 ++++++++++++++++++++-
> 1 file changed, 84 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> index abe495c2d033..3a540a2638d1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
> @@ -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;
please include:
netdev->xdp_zc_max_segs = ICE_MAX_BUF_TXD;
so that xsk ZC multi-buffer is also supported on SF netdevs.
> +
> + 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);
> --
> 2.42.0
>
next prev parent reply other threads:[~2024-06-27 11:14 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 11:24 [Intel-wired-lan] [iwl-next v5 00/15] ice: support devlink subfunction Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 01/15] ice: add new VSI type for subfunctions Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:06 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:06 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 02/15] ice: export ice ndo_ops functions Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:13 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:13 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 03/15] ice: add basic devlink subfunctions support Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:13 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:13 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 04/15] ice: treat subfunction VSI the same as PF VSI Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-06-27 11:07 ` [Intel-wired-lan] " Maciej Fijalkowski
2024-06-27 11:07 ` Maciej Fijalkowski
2024-06-27 12:31 ` [Intel-wired-lan] " Michal Swiatkowski
2024-06-27 12:31 ` Michal Swiatkowski
2024-07-23 11:14 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:14 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 05/15] ice: allocate devlink for subfunction Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-06-14 10:55 ` [Intel-wired-lan] " Simon Horman
2024-06-14 10:55 ` Simon Horman
2024-07-23 11:15 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:15 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 06/15] ice: base subfunction aux driver Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:16 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:16 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 07/15] ice: implement netdev for subfunction Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-06-27 11:13 ` Maciej Fijalkowski [this message]
2024-06-27 11:13 ` Maciej Fijalkowski
2024-06-27 12:32 ` [Intel-wired-lan] " Michal Swiatkowski
2024-06-27 12:32 ` Michal Swiatkowski
2024-07-23 11:20 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:20 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 08/15] ice: make representor code generic Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:21 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:21 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 09/15] ice: create port representor for SF Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:21 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:21 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 10/15] ice: don't set target VSI for subfunction Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:23 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:23 ` Romanowski, Rafal
2024-06-06 11:24 ` [Intel-wired-lan] [iwl-next v5 11/15] ice: check if SF is ready in ethtool ops Michal Swiatkowski
2024-06-06 11:24 ` Michal Swiatkowski
2024-07-23 11:24 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:24 ` Romanowski, Rafal
2024-06-06 11:25 ` [Intel-wired-lan] [iwl-next v5 12/15] ice: implement netdevice ops for SF representor Michal Swiatkowski
2024-06-06 11:25 ` Michal Swiatkowski
2024-06-14 11:02 ` [Intel-wired-lan] " Simon Horman
2024-06-14 11:02 ` Simon Horman
2024-07-23 11:24 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:24 ` Romanowski, Rafal
2024-06-06 11:25 ` [Intel-wired-lan] [iwl-next v5 13/15] ice: support subfunction devlink Tx topology Michal Swiatkowski
2024-06-06 11:25 ` Michal Swiatkowski
2024-07-23 11:25 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:25 ` Romanowski, Rafal
2024-06-06 11:25 ` [Intel-wired-lan] [iwl-next v5 14/15] ice: basic support for VLAN in subfunctions Michal Swiatkowski
2024-06-06 11:25 ` Michal Swiatkowski
2024-07-23 11:25 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:25 ` Romanowski, Rafal
2024-06-06 11:25 ` [Intel-wired-lan] [iwl-next v5 15/15] ice: allow to activate and deactivate subfunction Michal Swiatkowski
2024-06-06 11:25 ` Michal Swiatkowski
2024-07-23 11:26 ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23 11:26 ` Romanowski, Rafal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zn1JaxkObIWjkVAZ@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=jiri@nvidia.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=mateusz.polchlopek@intel.com \
--cc=michal.kubiak@intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pio.raczynski@gmail.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=shayd@nvidia.com \
--cc=sridhar.samudrala@intel.com \
--cc=wojciech.drewek@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.