dpdk: fix crash with chelsio pmd 38/27038/2
authorBenoît Ganne <bganne@cisco.com>
Wed, 13 May 2020 12:48:01 +0000 (14:48 +0200)
committerDamjan Marion <dmarion@me.com>
Thu, 14 May 2020 12:25:27 +0000 (12:25 +0000)
cxgbe PMD initializes its control channel as part of dev_configure(),
and trying to get link status prior to it will lead to a crash.

DPDK documentation loosely hints that we should not call any device
function before dev_start(), call link_state() only for the relevant
PMDs.

From DPDK API documentation:
The functions exported by the application Ethernet API to setup a device
designated by its port identifier must be invoked in the following
order:
    rte_eth_dev_configure()
    rte_eth_tx_queue_setup()
    rte_eth_rx_queue_setup()
    rte_eth_dev_start()
Then, the network application can invoke, in any order, the functions
exported by the Ethernet API to get the MAC address of a given device,
to get the speed and the status of a device physical link, to
receive/transmit [burst of] packets, and so on.

Type: fix

Change-Id: I12d2ab4d84e6bd72a9f695447e86f3222929c804
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/dpdk/device/init.c

index ae50b7a..0b80f5d 100644 (file)
@@ -259,7 +259,6 @@ dpdk_lib_init (dpdk_main_t * dm)
       int vlan_off;
       struct rte_eth_dev_info dev_info;
       struct rte_pci_device *pci_dev;
-      struct rte_eth_link l;
       dpdk_portid_t next_port_id;
       dpdk_device_config_t *devconf = 0;
       vlib_pci_addr_t pci_addr;
@@ -268,7 +267,6 @@ dpdk_lib_init (dpdk_main_t * dm)
       if (!rte_eth_dev_is_valid_port(i))
        continue;
 
-      rte_eth_link_get_nowait (i, &l);
       rte_eth_dev_info_get (i, &dev_info);
 
       if (dev_info.device == 0)
@@ -519,9 +517,13 @@ dpdk_lib_init (dpdk_main_t * dm)
 
              /* Cisco VIC */
            case VNET_DPDK_PMD_ENIC:
-             xd->port_type = port_type_from_link_speed (l.link_speed);
-             if (dm->conf->enable_tcp_udp_checksum)
-               dpdk_enable_l4_csum_offload (xd);
+                {
+                  struct rte_eth_link l;
+                  rte_eth_link_get_nowait (i, &l);
+                  xd->port_type = port_type_from_link_speed (l.link_speed);
+                  if (dm->conf->enable_tcp_udp_checksum)
+                    dpdk_enable_l4_csum_offload (xd);
+                }
              break;
 
              /* Intel Red Rock Canyon */
@@ -566,7 +568,11 @@ dpdk_lib_init (dpdk_main_t * dm)
              break;
 
            case VNET_DPDK_PMD_NETVSC:
-             xd->port_type = port_type_from_link_speed (l.link_speed);
+                {
+                  struct rte_eth_link l;
+                  rte_eth_link_get_nowait (i, &l);
+                  xd->port_type = port_type_from_link_speed (l.link_speed);
+                }
              break;
 
            default: