dpdk-19.11 method of supporting interface configuration rate duplex


The common igb electric interface network card needs to support the configuration of rate duplex, but the interface of rate duplex is not configured in dpdk-19.11. Therefore, it needs to be developed, and the implementation method needs to be determined by studying the driver codes of different network cards.

In this paper, the igb network card driver is described as an example.

Research on igb network card driver

The IGB network card driver in dpdk-19.11 is executing eth_ igb_ Duplex rate will be configured when starting up the interface.

The relevant codes are as follows:

1349     /* Setup link speed and duplex */
1350     speeds = &dev->data->dev_conf.link_speeds;
1351     if (*speeds == ETH_LINK_SPEED_AUTONEG) {
1352         hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
1353         hw->mac.autoneg = 1;
1354     } else {
1355         num_speeds = 0;
1356         autoneg = (*speeds & ETH_LINK_SPEED_FIXED) == 0;
1358         /* Reset */
1359         hw->phy.autoneg_advertised = 0;
1361         if (*speeds & ~(ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
1362                 ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
1363                 ETH_LINK_SPEED_1G | ETH_LINK_SPEED_FIXED)) {
1364             num_speeds = -1;
1365             goto error_invalid_config;
1366         }
1367         if (*speeds & ETH_LINK_SPEED_10M_HD) {
1368             hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
1369             num_speeds++;
1370         }   
1387         if (num_speeds == 0 || (!autoneg && (num_speeds > 1)))
1388             goto error_invalid_config;
1390         /* Set/reset the mac.autoneg based on the link speed,
1391          * fixed or not
1392          */
1393         if (!autoneg) {
1394             hw->mac.autoneg = 0;
1395             hw->mac.forced_speed_duplex =
1396                     hw->phy.autoneg_advertised;
1397         } else {
1398             hw->mac.autoneg = 1;
1399         }

1402     e1000_setup_link(hw);

The main logic of the above code is as follows:

  1. Get dev - > Data - > dev_ conf.link_ Link set in speeds variable_ Speeds to obtain the duplex configuration status of the rate
  2. According to link_ The value of the speeds variable is set to drive internal variables, such as HW - > PHY autoneg_ advertised,hw->mac. autoneg,hw->mac. forced_ speed_ Value of duplex
  3. Call e1000_setup_link configure the set duplex rate

According to the above process, we only need to set dev - > Data - > dev_ conf.link_ Speed, and then up the interface again to realize the rate duplex configuration.

Test verification process

After the above analysis, the method of speed duplex configuration of igb network card has been determined, and the feasibility needs to be verified.
Can be in E1000_ setup_ Execute the following code before calling the link function:

 hw->mac.autoneg = 0;
 hw->mac.forced_speed_duplex = ADVERTISE_100_FULL;

These two lines of code configure the interface rate duplex to force 100M full duplex. After modifying the code, use the kni program to test. The opposite interface is bound to the kernel driver. The test is valid!

Default rate duplex configuration of igb network card

After the setting scheme is determined, you cannot forget the default rate duplex configuration item of the igb network card. Generally speaking, in China_ eth_ dev_ Configure failed dev_conf setting link_ The value of speeds defaults to 0.

eth_ igb_ dev_ The following code in the init function configures the interface to use the self negotiation mode, and specifies the negotiation rate as all supported rates and duplex mode.

 793     hw->mac.autoneg = 1;
 794     hw->phy.autoneg_wait_to_complete = 0;
 795     hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;

dpdk-19.11 get the rate duplex configuration supported by the interface

Before setting the duplex rate, you can add some checks to check whether the mode to be set is supported by the current network card. You can call rte_eth_dev_info_get function to get dev_info structure, dev_ Speed in info structure_ The CAPA field represents the rate duplex configuration supported by the current network card.

For IGB network card, speed_capa field via eth_ igb_ infos_ The get function is filled with the following code:

2286     dev_info->speed_capa = ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
2287             ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
2288             ETH_LINK_SPEED_1G;

After you get it, you can check it!


Taking igb driver as an example, this paper describes the method of dpdk-19.11 supporting interface configuration rate duplex. This method is suitable for multiple drivers and is a relatively general method. Rate duplex configuration is also a common function that the network card driver should provide externally. However, the processing process of dpdk here is somewhat special. It focuses the configuration on dev - > Data - > dev_ conf.link_ The speed variable is set!

Keywords: dpdk

Added by jmantra on Fri, 11 Feb 2022 12:16:26 +0200