summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-05-09 19:50:26 +0200
committerDave Wallace <dwallacelf@gmail.com>2017-05-10 16:17:49 +0000
commit4fb27eed7e1f986394e20035a24476237c7e6f60 (patch)
treebb8f67dfb4b1d3a4e8a6b3270c45836fc77d18a9 /src/plugins
parentdf82ec8fe7d91467c8b479bba74c761c0a6ffc59 (diff)
dpdk: refactor interface speed detection
- Adds VirtualFucntionEthernet for VFs - Enables MLX4 driver Change-Id: I163300e68edbe033227f641bdfcfe5918cbe58cf Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/device/dpdk.h5
-rw-r--r--src/plugins/dpdk/device/format.c8
-rwxr-xr-xsrc/plugins/dpdk/device/init.c127
3 files changed, 42 insertions, 98 deletions
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index 583d2cd932b..7e2901bbb30 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -72,6 +72,7 @@ extern vlib_node_registration_t dpdk_input_node;
_ ("net_bonding", BOND) \
_ ("net_fm10k", FM10K) \
_ ("net_cxgbe", CXGBE) \
+ _ ("net_mlx4", MLX4) \
_ ("net_mlx5", MLX5) \
_ ("net_dpaa2", DPAA2)
#else
@@ -91,6 +92,7 @@ extern vlib_node_registration_t dpdk_input_node;
_ ("rte_bond_pmd", BOND) \
_ ("net_fm10k", FM10K) \
_ ("net_cxgbe", CXGBE) \
+ _ ("net_mlx4", MLX4) \
_ ("net_mlx5", MLX5) \
_ ("net_dpaa2", DPAA2)
#endif
@@ -114,6 +116,7 @@ typedef enum
VNET_DPDK_PORT_TYPE_ETH_BOND,
VNET_DPDK_PORT_TYPE_ETH_SWITCH,
VNET_DPDK_PORT_TYPE_AF_PACKET,
+ VNET_DPDK_PORT_TYPE_ETH_VF,
VNET_DPDK_PORT_TYPE_UNKNOWN,
} dpdk_port_type_t;
@@ -185,7 +188,7 @@ typedef struct
#define DPDK_DEVICE_FLAG_ADMIN_UP (1 << 0)
#define DPDK_DEVICE_FLAG_PROMISC (1 << 1)
#define DPDK_DEVICE_FLAG_PMD (1 << 2)
-#define DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE (1 << 3)
+
#define DPDK_DEVICE_FLAG_MAYBE_MULTISEG (1 << 4)
#define DPDK_DEVICE_FLAG_HAVE_SUBIF (1 << 5)
#define DPDK_DEVICE_FLAG_HQOS (1 << 6)
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index 389cd8b6c33..3b75563d0b5 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -187,6 +187,10 @@ format_dpdk_device_name (u8 * s, va_list * args)
device_name = "EthernetSwitch";
break;
+ case VNET_DPDK_PORT_TYPE_ETH_VF:
+ device_name = "VirtualFunctionEthernet";
+ break;
+
case VNET_DPDK_PORT_TYPE_AF_PACKET:
rte_eth_dev_info_get (i, &dev_info);
return format (s, "af_packet%d", dm->devices[i].port_id);
@@ -264,6 +268,10 @@ format_dpdk_device_type (u8 * s, va_list * args)
dev_type = "Chelsio T4/T5";
break;
+ case VNET_DPDK_PMD_MLX4:
+ dev_type = "Mellanox ConnectX-3 Family";
+ break;
+
case VNET_DPDK_PMD_MLX5:
dev_type = "Mellanox ConnectX-4 Family";
break;
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 3aba031c285..69959c05df2 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -55,6 +55,24 @@ static struct rte_eth_conf port_conf_template = {
},
};
+static dpdk_port_type_t
+port_type_from_speed_capa (struct rte_eth_dev_info *dev_info)
+{
+
+ if (dev_info->speed_capa & ETH_LINK_SPEED_100G)
+ return VNET_DPDK_PORT_TYPE_ETH_100G;
+ else if (dev_info->speed_capa & ETH_LINK_SPEED_40G)
+ return VNET_DPDK_PORT_TYPE_ETH_40G;
+ else if (dev_info->speed_capa & ETH_LINK_SPEED_25G)
+ return VNET_DPDK_PORT_TYPE_ETH_25G;
+ else if (dev_info->speed_capa & ETH_LINK_SPEED_10G)
+ return VNET_DPDK_PORT_TYPE_ETH_10G;
+ else if (dev_info->speed_capa & ETH_LINK_SPEED_1G)
+ return VNET_DPDK_PORT_TYPE_ETH_1G;
+
+ return VNET_DPDK_PORT_TYPE_UNKNOWN;
+}
+
static u32
dpdk_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
@@ -332,19 +350,25 @@ dpdk_lib_init (dpdk_main_t * dm)
switch (xd->pmd)
{
- /* 1G adapters */
+ /* Drivers with valid speed_capa set */
case VNET_DPDK_PMD_E1000EM:
case VNET_DPDK_PMD_IGB:
- case VNET_DPDK_PMD_IGBVF:
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_1G;
+ case VNET_DPDK_PMD_IXGBE:
+ case VNET_DPDK_PMD_I40E:
+ case VNET_DPDK_PMD_CXGBE:
+ case VNET_DPDK_PMD_MLX4:
+ case VNET_DPDK_PMD_MLX5:
+ xd->port_type = port_type_from_speed_capa (&dev_info);
break;
- /* 10G adapters */
- case VNET_DPDK_PMD_IXGBE:
+ /* SR-IOV VFs */
+ case VNET_DPDK_PMD_IGBVF:
case VNET_DPDK_PMD_IXGBEVF:
+ case VNET_DPDK_PMD_I40EVF:
case VNET_DPDK_PMD_THUNDERX:
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
+ xd->port_type = VNET_DPDK_PORT_TYPE_ETH_VF;
break;
+
case VNET_DPDK_PMD_DPAA2:
xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
break;
@@ -352,102 +376,12 @@ dpdk_lib_init (dpdk_main_t * dm)
/* Cisco VIC */
case VNET_DPDK_PMD_ENIC:
rte_eth_link_get_nowait (i, &l);
- xd->flags |= DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE;
if (l.link_speed == 40000)
xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
else
xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
break;
- /* Intel Fortville */
- case VNET_DPDK_PMD_I40E:
- case VNET_DPDK_PMD_I40EVF:
- xd->flags |= DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE;
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
-
- if (dev_info.speed_capa & ETH_LINK_SPEED_40G)
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
- else if (dev_info.speed_capa & ETH_LINK_SPEED_25G)
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_25G;
- else if (dev_info.speed_capa & ETH_LINK_SPEED_10G)
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
- else
- xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN;
- break;
-
- case VNET_DPDK_PMD_CXGBE:
- switch (dev_info.pci_dev->id.device_id)
- {
- case 0x540d: /* T580-CR */
- case 0x5410: /* T580-LP-cr */
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
- break;
- case 0x5403: /* T540-CR */
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
- break;
- default:
- xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN;
- }
- break;
-
- case VNET_DPDK_PMD_MLX5:
- {
- char *pn_100g[] = { "MCX415A-CCAT", "MCX416A-CCAT",
- "MCX556A-ECAT", "MCX556A-EDAT", "MCX555A-ECAT",
- "MCX515A-CCAT", "MCX516A-CCAT", "MCX516A-CDAT", 0
- };
- char *pn_40g[] = { "MCX413A-BCAT", "MCX414A-BCAT",
- "MCX415A-BCAT", "MCX416A-BCAT", "MCX4131A-BCAT", 0
- };
- char *pn_10g[] = { "MCX4111A-XCAT", "MCX4121A-XCAT", 0 };
-
- vlib_pci_device_t *pd = vlib_get_pci_device (&pci_addr);
- u8 *pn = 0;
- char **c;
- int found = 0;
- pn = format (0, "%U%c",
- format_vlib_pci_vpd, pd->vpd_r, "PN", 0);
-
- if (!pn)
- break;
-
- c = pn_100g;
- while (!found && c[0])
- {
- if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0)
- {
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_100G;
- break;
- }
- c++;
- }
-
- c = pn_40g;
- while (!found && c[0])
- {
- if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0)
- {
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G;
- break;
- }
- c++;
- }
-
- c = pn_10g;
- while (!found && c[0])
- {
- if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0)
- {
- xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G;
- break;
- }
- c++;
- }
-
- vec_free (pn);
- }
-
- break;
/* Intel Red Rock Canyon */
case VNET_DPDK_PMD_FM10K:
xd->port_type = VNET_DPDK_PORT_TYPE_ETH_SWITCH;
@@ -472,7 +406,6 @@ dpdk_lib_init (dpdk_main_t * dm)
break;
case VNET_DPDK_PMD_BOND:
- xd->flags |= DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE;
xd->port_type = VNET_DPDK_PORT_TYPE_ETH_BOND;
xd->port_id = bond_ether_port_id++;
break;