liquidio: Switchdev support for LiquidIO NIC
Subsystems (3)
v2 cover liquidio: Switchdev support for LiquidIO NIC
From: Vijaya Mohan Guvva <[email protected]>
patch1 of this patch set adds switchdev support for SRIOV capable LiquidIO NIC, so that for every SRIOV VF on LiquidIO, a representor netdev is created on hypervisor. It also has changes to send representor interface configurations like admin state and MTU to LiquidIO firmware and to retrieve HW counted VF stats for VF representor.
patch2 adds support for switchdev enable/disable from devlink
Patchset Change Log:
V1 -> V2:
* Name the representors "pfXvfY".
* Drop patch3 (ethtool support for switchdev ports) that was in V1 because it's not necessary.
Vijaya Mohan Guvva (2):
liquidio: switchdev support for LiquidIO NIC
liquidio: Configure switchdev with devlink
drivers/net/ethernet/cavium/Kconfig | 1 + drivers/net/ethernet/cavium/liquidio/Makefile | 2 +- drivers/net/ethernet/cavium/liquidio/lio_main.c | 117 ++++ drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c | 628 +++++++++++++++++++++ drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h | 47 ++ .../net/ethernet/cavium/liquidio/liquidio_common.h | 51 ++ .../net/ethernet/cavium/liquidio/octeon_device.h | 14 + 7 files changed, 859 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c create mode 100644 drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h
Signature · 1 line
2.9.0
PATCH v2 1/2 liquidio: switchdev support for LiquidIO NIC
From: Vijaya Mohan Guvva <[email protected]>
Enable switchdev for SRIOV capable LiquidIO NIC. It registers a representor netdev (with switchdev_ops) for each SRIOV VF created. It also has changes to send representor interface configurations like admin state and MTU to LiquidIO firmware and to retrieve HW counted VF stats for VF representor.
--- drivers/net/ethernet/cavium/liquidio/Makefile | 2 +- drivers/net/ethernet/cavium/liquidio/lio_main.c | 28 + drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c | 622 +++++++++++++++++++++ drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h | 47 ++ .../net/ethernet/cavium/liquidio/liquidio_common.h | 49 ++ .../net/ethernet/cavium/liquidio/octeon_device.h | 7 + 6 files changed, 754 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c create mode 100644 drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h
drivers/net/ethernet/cavium/liquidio/Makefile +1 -1
@@ -17,7 +17,7 @@ liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \ octeon_droq.o \ octeon_nic.o -liquidio-objs := lio_main.o octeon_console.o $(liquidio-y) +liquidio-objs := lio_main.o octeon_console.o lio_vf_rep.o $(liquidio-y) obj-$(CONFIG_LIQUIDIO_VF) += liquidio_vf.o
drivers/net/ethernet/cavium/liquidio/lio_main.c +28 -0
@@ -21,6 +21,7 @@#include <linux/firmware.h> #include <net/vxlan.h> #include <linux/kthread.h> +#include <net/switchdev.h> #include "liquidio_common.h" #include "octeon_droq.h" #include "octeon_iq.h"
@@ -3309,6 +3310,32 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx,return 0 ; } +static int +lio_pf_switchdev_attr_get (struct net_device *dev,struct switchdev_attr *attr) +{ +struct lio *lio =GET_LIO (dev); +struct octeon_device *oct = lio->oct_dev; +char phy_switch_id[] = {0x17 ,0x7d ,0x97 ,0x02 ,0x00 }; +int len =sizeof (phy_switch_id); + +switch (attr->id) { +case SWITCHDEV_ATTR_ID_PORT_PARENT_ID : + phy_switch_id[len -1 ] = oct->pf_num; + attr->u.ppid.id_len = len; +memcpy (attr->u.ppid.id, phy_switch_id, len); +break ; + +default : +return -EOPNOTSUPP ; + } + +return 0 ; +} + +static const struct switchdev_ops lio_pf_switchdev_ops = { + .switchdev_port_attr_get = lio_pf_switchdev_attr_get, +}; +static const struct net_device_ops lionetdevops = { .ndo_open = liquidio_open, .ndo_stop = liquidio_stop,
@@ -3583,6 +3610,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)* netdev tasks. */ netdev->netdev_ops = &lionetdevops; +SWITCHDEV_SET_OPS (netdev, &lio_pf_switchdev_ops); lio =GET_LIO (netdev);
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c new file +622 -0
622 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.h new file +47 -0
47 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/liquidio_common.h +49 -0
59 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/octeon_device.h +7 -0
@@ -391,6 +391,11 @@ struct octeon_ioq_vector {u32 ioq_num; }; +struct lio_vf_rep_list { +int num_vfs; +struct net_device *ndev[CN23XX_MAX_VFS_PER_PF ]; +}; +/** The Octeon device. * Each Octeon device has this structure to represent all its * components.
@@ -568,6 +573,8 @@ struct octeon_device {atomic_t *adapter_fw_state;/* per-adapter, lio_fw_state */ bool ptp_enable; + +struct lio_vf_rep_list vf_rep_list; };#define OCT_DRV_ONLINE 1
Signature · 1 line
2.9.0
PATCH v2 2/2 liquidio: Configure switchdev with devlink
In reply to Felix ManlunasFrom: Vijaya Mohan Guvva <[email protected]>
Enable and disable switchdev on SRIOV capable LiquidIO NIC with devlink. Create representor netdev for each SRIOV VF function on SRIOV enable and and do the cleanup on SRIOV disable.
--- drivers/net/ethernet/cavium/Kconfig | 1 + drivers/net/ethernet/cavium/liquidio/lio_main.c | 89 ++++++++++++++++++++++ drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c | 6 ++ .../net/ethernet/cavium/liquidio/liquidio_common.h | 2 + .../net/ethernet/cavium/liquidio/octeon_device.h | 7 ++ 5 files changed, 105 insertions(+)
drivers/net/ethernet/cavium/Kconfig +1 -0
@@ -53,6 +53,7 @@ config THUNDER_NIC_RGX config LIQUIDIO tristate "Cavium LiquidIO support" depends on 64BIT + depends on MAY_USE_DEVLINK imply PTP_1588_CLOCK select FW_LOADER select LIBCRC32C
drivers/net/ethernet/cavium/liquidio/lio_main.c +89 -0
137 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +6 -0
@@ -516,6 +516,9 @@ lio_vf_rep_create(struct octeon_device *oct)struct net_device *ndev;int i, num_vfs; +if (oct->eswitch_mode !=DEVLINK_ESWITCH_MODE_SWITCHDEV ) +return 0 ; +if (!oct->sriov_info.sriov_enabled)return 0 ;
@@ -600,6 +603,9 @@ lio_vf_rep_destroy(struct octeon_device *oct)struct net_device *ndev;int i; +if (oct->eswitch_mode !=DEVLINK_ESWITCH_MODE_SWITCHDEV ) +return ; +if (!oct->sriov_info.sriov_enabled)return ;
drivers/net/ethernet/cavium/liquidio/liquidio_common.h +2 -0
@@ -110,6 +110,8 @@ enum octeon_tag_type {#define MAX_IOQ_INTERRUPTS_PER_PF (64 * 2)#define MAX_IOQ_INTERRUPTS_PER_VF (8 * 2) +#define LIQUIDIO_SWITCHDEV_CAP 0x2 +#define SCR2_BIT_FW_LOADED 63/* App specific capabilities from firmware to pf driver */
drivers/net/ethernet/cavium/liquidio/octeon_device.h +7 -0
@@ -23,6 +23,7 @@#define _OCTEON_DEVICE_H_#include <linux/interrupt.h> +#include <net/devlink.h> /** PCI VendorId Device Id */ #define OCTEON_CN68XX_PCIID 0x91177d
@@ -396,6 +397,10 @@ struct lio_vf_rep_list {struct net_device *ndev[CN23XX_MAX_VFS_PER_PF ]; }; +struct lio_devlink_priv { +struct octeon_device *oct; +}; +/** The Octeon device. * Each Octeon device has this structure to represent all its * components.
@@ -575,6 +580,8 @@ struct octeon_device {bool ptp_enable;struct lio_vf_rep_list vf_rep_list; +struct devlink *devlink; +enum devlink_eswitch_mode eswitch_mode; };#define OCT_DRV_ONLINE 1
Signature · 1 line
2.9.0
Re: [PATCH V2 net-next 1/2] liquidio: switchdev support for LiquidIO NIC
In reply to Felix ManlunasQuoted 8 lines · Felix Manlunas
From: Vijaya Mohan Guvva <[email protected]>
Enable switchdev for SRIOV capable LiquidIO NIC. It registers a representor netdev (with
switchdev_ops) for each SRIOV VF created. It also has changes to send representor interface configurations like admin state and MTU to LiquidIO firmware and to retrieve HW counted VF stats for VF representor.
Quoted 4 lines
Signed-off-by Vijaya Mohan Guvva <[email protected]>Signed-off-by Satanand Burla <[email protected]>Signed-off-by Raghu Vatsavayi <[email protected]>Signed-off-by Felix Manlunas <[email protected]>
Thanks for making the changes! One more thing caught my eye this time around.
Quoted 33 lines
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c new file +32
-0+static int +lio_pf_switchdev_attr_get (struct net_device *dev,struct switchdev_attr *attr) +{ +struct lio *lio =GET_LIO (dev); +struct octeon_device *oct = lio->oct_dev; +char phy_switch_id[] = {0x17 ,0x7d ,0x97 ,0x02 ,0x00 }; +int len =sizeof (phy_switch_id); + +switch (attr->id) { +case SWITCHDEV_ATTR_ID_PORT_PARENT_ID : + phy_switch_id[len -1 ] = oct->pf_num; + attr->u.ppid.id_len = len; +memcpy (attr->u.ppid.id, phy_switch_id, len); +break ; + +default : +return -EOPNOTSUPP ; + } + +return 0 ; +} +static int +lio_vf_rep_attr_get (struct net_device *dev,struct switchdev_attr *attr) +{ +char phy_switch_id[] = {0x17 ,0x7d ,0x97 ,0x02 ,0x00 }; +struct lio_vf_rep_desc *vf_rep =netdev_priv (dev); +struct octeon_device *oct = vf_rep->oct; +int len =sizeof (phy_switch_id); + +switch (attr->id) { +case SWITCHDEV_ATTR_ID_PORT_PARENT_ID : + phy_switch_id[len -1 ] = oct->pf_num;
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c line 478
Quoted 10 lines
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c new file +10
-0+ attr->u.ppid.id_len = len; +memcpy (attr->u.ppid.id, phy_switch_id, len); +break ; + +default : +return -EOPNOTSUPP ; + } + +return 0 ; +}
SWITCHDEV_ATTR_ID_PORT_PARENT_ID is generally used to determine whether two ports belong to the same switch. Do you not want to support rules which redirect packets from one PF (and it's VFs) to the other?
Also if you plug two cards into one system, the above will make you offload redirect between the cards. Is that what you want? Commonly the MAC address of the first port or serial number would be used here to make sure IDs are unique for each device.
RE: [PATCH V2 net-next 1/2] liquidio: switchdev support for LiquidIO NIC
Thanks Jakub for reviewing the changes.
Quoted 4 lines
SWITCHDEV_ATTR_ID_PORT_PARENT_IDis generally used to determine whether two ports belong to the same switch. Do you not want to support rules which redirect packets from one PF (and it's VFs) to the other?
We would be presenting each PF as a separate switch in switchdev model. So, will be returning separate switchID for each PF.
Quoted 4 lines
Also if you plug two cards into one system, the above will make you offload redirect between the cards. Is that what you want? Commonly the MAC address of the first port or serial number would be used here to make sure IDs are unique for each device.
This was done to have static UDEV rules which works on all liquidIO devices. We will resubmit patches for using mac address as switchID.
Thanks,
Vijay