On Tue, Mar 13, 2018 at 02:54:44PM -0700, Yongseok Koh wrote: > On Mon, Mar 12, 2018 at 02:43:18PM +0100, Nelio Laranjeiro wrote: > > This behavior is mixed between what should be handled by the application > > and what is under PMD responsibility. > > > > According to DPDK API: > > - link_update() should only query the link status [1] > > - link_set_{up,down}() should only set the link to the according status [1] > > - dev_{start,stop}() should enable/disable traffic reception/emission [2] > > The description of rte_eth_dev_set_link_up() is [1] : > The device rx/tx functionality will be disabled if success, and it can > be re-enabled with a call to rte_eth_dev_set_link_up() > > This means, if user runs "set link-down port 0" on testpmd, traffic should > stop > by disabling Rx/Tx on device. But unfortunately, mlx5 doesn't have a way to > stop > device but it rather relies on kernel implementation - e.g. SIOCSIFFLAGS. So, > even if the command is run, traffic goes on. I guess the original > implementation might be needed to workaround this situation. > > Shall we talk to HW and driver people regarding how to access dev (or PHY) > from > user-level? > > [1] > http://dpdk.org/doc/api/rte__ethdev_8h.html#a51d7a0d2bb4202f9ebf9f174ba1f6e5c
As you mentioned, since the mlx5 PMD doesn't really own the device, it doesn't have the final say on whether traffic still flows after putting the link down at the DPDK level. It has been worked around by replacing burst callbacks with no-ops since up/down ethops were added [3]. Problem is that updating burst callback pointers while traffic is flowing has always been more or less unsafe. It's not necessarily atomic and only really safe to do when traffic is guaranteed to be stopped (i.e. after dev_stop() was called by the application). Moreover these no-ops don't prevent device RX queues from still getting filled up. Looking at the original implementation [4][5], other PMDs simply have to turn off the laser or some such which doesn't prevent RX/TX functions from working as before except traffic happens to be lost instead of ending up rejected by dedicated burst callbacks. The main purpose of up/down callbacks and the reason they were implemented in mlx5 is that customers want to see something happen at the carrier level on the remote end (as with other PMDs) when a DPDK port is brought up or down. This is why they are seldom implemented in other PMDs for VF eth_dev_ops given those can't control PHY. Actively preventing traffic is secondary and either has a performance impact (permanent status check in the data plane) or is somewhat unsafe (live replacement of burst callbacks). Given the above, I'm in favor of removing the no-ops. Applications are the ones performing up/down calls, they manage the administrative status of interfaces and should refrain from calling TX/RX burst functions afterward. Carrier status is left to PMDs and can't necessarily be modified. [3] 62072098b54e ("mlx5: support setting link up or down") [4] 915e67837586 ("ethdev: API for link up and down") [5] c38f4f83edc0 ("ixgbe: link up and down") -- Adrien Mazarguil 6WIND