net/tap: add additional management ops
cover net/tap: add additional management ops
Add a few eth_dev ops to the tap PMD for completeness. We want it to behave as much as possible as a standard PMD.
Pascal Mazon (6):
net/tap: add MAC address management ops
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add MTU management
net/tap: add packet type management
net/tap: add flow control management
doc/guides/nics/features/tap.ini | 6 ++ drivers/net/tap/rte_eth_tap.c | 207 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 200 insertions(+), 13 deletions(-)
Signature · 1 line
2.8.0.rc0
PATCH 1/6 net/tap: add MAC address management ops
Set a random MAC address when probing the device, as to not leave an empty MAC in pmd->eth_addr.
This MAC will be set on the tap netdevice as soon as it's been created using tun_alloc(). As the tap_mac_add() function depend on the fd in the first rxq, move code from tun_alloc() to tap_setup_queue(), after it's been set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 88 ++++++++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 13 deletions(-)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +75 -13
142 lines not on this page · raw message
Signature · 1 line
2.8.0.rc0
PATCH 2/6 net/tap: add speed capabilities
In reply to Pascal MazonTap PMD is flexible, it supports any speed.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ; + +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Signature · 1 line
2.8.0.rc0
Re: [PATCH 2/6] net/tap: add speed capabilities
Quoted 51 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35 +++++++++++++++++++++++++++++++++++2 files changed, 36 insertions(+)doc/guides/nics/features/tap.ini +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Ydrivers/net/tap/rte_eth_tap.c +20
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ;
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 383
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ;
In the real world the NIC may only support 50G an not say 10M, so in that case this code would be wrong as it would set all of the speeds up to 50G. I do not think the code should be changed, but I add a comment to tell the developer the issue here. I do not want someone copying the code and thinking is i correct for a real device.
Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +4
-0+ +return capa; +} +static void
tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info){drivers/net/tap/rte_eth_tap.c +1
-0@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); }
Quoted 4 lines
static void
Signature · 1 line
2.8.0.rc0
Regards,
Keith
Re: [PATCH 2/6] net/tap: add speed capabilities
Quoted 61 lines · Keith
Quoted 61 lines
On Mar 3, 2017, at 3:46 AM, Pascal Mazon <[email protected]> wrote:
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35
+++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
d9b47a003654..dad5a0561087100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini(quoted diff) +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex994c8be701c8..6670dfbb35ce100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +28
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused) return 0; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ;
Quoted 9 lines
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 383
Quoted 2 lines
drivers/net/tap/rte_eth_tap.c +2
-0+if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ;In the real world the NIC may only support 50G an not say 10M, so in that case this code would be wrong as it would set all of the speeds up to 50G. I do not think the code should be changed, but I add a comment to tell the developer the issue here. I do not want someone copying the code and thinking is i correct for a real device.
That's true for actual hardware. But tap is completely virtual, so actually it could support any speed (it is limited by userland-kernel communication speed).
What speed would you rather have the tap PMD report as capable of?
Best regards,
Pascal
Quoted 22 lines
Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +4
-0+ +return capa; +} +static void
tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info){(quoted diff) +0
-0@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct
rte_eth_dev_info*dev_info)dev_info->max_tx_queues=internals->nb_queues; dev_info->min_rx_bufsize = 0; dev_info->pci_dev = NULL;drivers/net/tap/rte_eth_tap.c +1
-0+ dev_info->speed_capa =tap_dev_speed_capa ();}
Quoted 4 lines
static void
Signature · 1 line
2.8.0.rc0Regards,
Keith
Re: [PATCH 2/6] net/tap: add speed capabilities
Quoted 77 lines · Pascal Mazon
Quoted 61 lines · Keith
Quoted 61 lines
On Mar 3, 2017, at 3:46 AM, Pascal Mazon <[email protected]> wrote:
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35
+++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
d9b47a003654..dad5a0561087100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini(quoted diff) +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex994c8be701c8..6670dfbb35ce100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +28
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused) return 0; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ;Quoted 9 lines
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 383
Quoted 2 lines
drivers/net/tap/rte_eth_tap.c +2
-0+if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ;In the real world the NIC may only support 50G an not say 10M, so in that case this code would be wrong as it would set all of the speeds up to 50G. I do not think the code should be changed, but I add a comment to tell the developer the issue here. I do not want someone copying the code and thinking is i correct for a real device.
Quoted 5 lines
That's true for actual hardware. But tap is completely virtual, so actually it could support any speed (it is limited by userland-kernel communication speed).
What speed would you rather have the tap PMD report as capable of?
This note was a very minor picky point and you can ignore my comment here. It is not worth the time to deal with and you have better things to do :-)
Quoted 27 lines
Best regards,
PascalQuoted 22 lines
Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +4
-0+ +return capa; +} +static void
tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info){(quoted diff) +0
-0@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct
rte_eth_dev_info*dev_info)dev_info->max_tx_queues=internals->nb_queues; dev_info->min_rx_bufsize = 0; dev_info->pci_dev = NULL;drivers/net/tap/rte_eth_tap.c +1
-0+ dev_info->speed_capa =tap_dev_speed_capa ();}
Quoted 4 lines
static void
Signature · 1 line
2.8.0.rc0Regards,
Keith
Regards,
Keith
PATCH 3/6 net/tap: add multicast addresses management
In reply to Pascal MazonA tap netdevice actually receives every packet, without any filtering whatsoever. There is no need for any multicast address registration to receive multicast packets.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y
drivers/net/tap/rte_eth_tap.c +13 -0
@@ -712,6 +712,18 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,return 0 ; } +static int +tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mc_addr_set __rte_unused, + uint32_t nb_mc_addr __rte_unused) +{ +/* +* Nothing to do actually: the tap has no filtering whatsoever, every +* packet is received. +*/ +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -732,6 +744,7 @@ static const struct eth_dev_ops ops = { .mac_addr_remove = tap_mac_remove, .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, + .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH 4/6 net/tap: add MTU management
In reply to Pascal MazonThe MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y
drivers/net/tap/rte_eth_tap.c +37 -0
@@ -724,6 +724,42 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; +int err, s; + + s =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (s <0 ) { +RTE_LOG (ERR ,PMD , +"Unable to get a socket for %s to set flags: %s\n" , + pmd->name,strerror (errno)); +return -1 ; + } +memset (&ifr,0 ,sizeof (ifr)); +strncpy (ifr.ifr_name, pmd->name,IFNAMSIZ ); + err =ioctl (s,SIOCGIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to get %s device MTU: %s\n" , + pmd->name,strerror (errno)); +close (s); +return -1 ; + } + ifr.ifr_mtu = mtu; + err =ioctl (s,SIOCSIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to set %s mtu %d: %s\n" , + pmd->name, mtu,strerror (errno)); +close (s); +return -1 ; + } +close (s); + dev->data->mtu = mtu; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -745,6 +781,7 @@ static const struct eth_dev_ops ops = { .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, .set_mc_addr_list = tap_set_mc_addr_list, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
Re: [PATCH 4/6] net/tap: add MTU management
Quoted 39 lines · Pascal Mazon
The MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 37 +++++++++++++++++++++++++++++++++++++2 files changed, 38 insertions(+)doc/guides/nics/features/tap.ini +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y+MTU update = Y
Multicast MAC filter = Y
Speed capabilities = Y
Unicast MAC filter = Ydrivers/net/tap/rte_eth_tap.c +6
-0@@ -724,6 +724,42 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; +int err, s;
drivers/net/tap/rte_eth_tap.c tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, · line 742
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+ + s =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (s <0 ) { +RTE_LOG (ERR ,PMD , +"Unable to get a socket for %s to set flags: %s\n" , + pmd->name,strerror (errno)); +return -1 ; + } +memset (&ifr,0 ,sizeof (ifr)); +strncpy (ifr.ifr_name, pmd->name,IFNAMSIZ );
This needs to be converted to a snprintf() to avoid overflow.
Quoted 34 lines
drivers/net/tap/rte_eth_tap.c +21
-0+ err =ioctl (s,SIOCGIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to get %s device MTU: %s\n" , + pmd->name,strerror (errno)); +close (s); +return -1 ; + } + ifr.ifr_mtu = mtu; + err =ioctl (s,SIOCSIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to set %s mtu %d: %s\n" , + pmd->name, mtu,strerror (errno)); +close (s); +return -1 ; + } +close (s); + dev->data->mtu = mtu; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -745,6 +781,7 @@ static const struct eth_dev_ops ops = { .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, .set_mc_addr_list = tap_set_mc_addr_list, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };Signature · 1 line
2.8.0.rc0
Regards,
Keith
Re: [PATCH 4/6] net/tap: add MTU management
Quoted 46 lines · Keith
Quoted 46 lines
On Mar 3, 2017, at 3:46 AM, Pascal Mazon <[email protected]> wrote:
The MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 37
+++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
6878a9b8fd17..6aa11874e2bc100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini(quoted diff) +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y+MTU update = Y
Multicast MAC filter = Y
Speed capabilities = Y
Unicast MAC filter = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex131c09fbc1a5..64b84cd76321100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +11
-0@@ -724,6 +724,42 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, return 0; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; +int err, s; + + s =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (s <0 ) { + RTE_LOG(ERR, PMD, + "Unable to get a socket for %s to set
Quoted 9 lines
drivers/net/tap/rte_eth_tap.c tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, · line 742
Quoted 6 lines
drivers/net/tap/rte_eth_tap.c +5
-0flags: %s\n", + pmd->name, strerror(errno)); +return -1 ; + } +memset (&ifr,0 ,sizeof (ifr)); +strncpy (ifr.ifr_name, pmd->name,IFNAMSIZ );This needs to be converted to a
snprintf()to avoid overflow.
Ok, I'll do that in version 2.
Regards,
Pascal
Quoted 40 lines
Quoted 36 lines
drivers/net/tap/rte_eth_tap.c +20
-0+ err =ioctl (s,SIOCGIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to get %s device MTU: %s\n", + pmd->name,strerror (errno)); +close (s); +return -1 ; + } + ifr.ifr_mtu = mtu; + err =ioctl (s,SIOCSIFMTU , &ifr); +if (err <0 ) { + RTE_LOG(WARNING, PMD, "Unable to set %s mtu %d: %s\n", + pmd->name, mtu, strerror(errno)); +close (s); +return -1 ; + } +close (s); + dev->data->mtu = mtu; +return 0 ; +} +static const struct
eth_dev_opsops = {
.dev_start =tap_dev_start,
.dev_stop =tap_dev_stop,drivers/net/tap/rte_eth_tap.c +1
-0@@ -745,6 +781,7 @@ static const struct eth_dev_ops ops = { .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, .set_mc_addr_list = tap_set_mc_addr_list, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };Signature · 1 line
2.8.0.rc0Regards,
Keith
PATCH 5/6 net/tap: add packet type management
In reply to Pascal MazonAdvertize RTE_PTYPE_UNKNOWN since tap does not report any packet type.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +15 -0
@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
@@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;
@@ -760,6 +763,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -784,6 +798,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Signature · 1 line
2.8.0.rc0
Re: [PATCH 5/6] net/tap: add packet type management
Quoted 48 lines · Pascal Mazon
Advertize
RTE_PTYPE_UNKNOWNsince tap does not report any packet type.Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 15 +++++++++++++++2 files changed, 16 insertions(+)doc/guides/nics/features/tap.ini +0
-0@@ -13,6 +13,7 @@ MTU update = YMulticast MAC filter = Y
Speed capabilities = Y
Unicast MAC filter = Y
+Packet type parsing = YOther kdrv = Y ARMv7 = Y ARMv8 = Ydrivers/net/tap/rte_eth_tap.c +3
-0@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h> @@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;@@ -760,6 +763,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; }
drivers/net/tap/rte_eth_tap.c tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) · line 775
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +}
Can we just add the code to grab the ptype value instead of just saying not supported.
The original code would just return an error from ethdev correct, what was wrong with that one. I would like to see the tap PMD just return the ptype would that not be more useful?
Quoted 11 lines
drivers/net/tap/rte_eth_tap.c +2
-0+static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -784,6 +798,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, };
Quoted 4 lines
static int
Signature · 1 line
2.8.0.rc0
Regards,
Keith
Re: [PATCH 5/6] net/tap: add packet type management
Quoted 65 lines · Keith
Quoted 51 lines
On Mar 3, 2017, at 3:46 AM, Pascal Mazon <[email protected]> wrote:
Advertize
RTE_PTYPE_UNKNOWNsince tap does not report any packet type.Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 15 +++++++++++++++2 files changed, 16 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
6aa11874e2bc..7f3f4d661dd7100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini(quoted diff) +0
-0@@ -13,6 +13,7 @@ MTU update = YMulticast MAC filter = Y
Speed capabilities = Y
Unicast MAC filter = Y
+Packet type parsing = YOther kdrv = Y ARMv7 = Y ARMv8 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex64b84cd76321..e4af36a6d142100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +3
-0@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h> @@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;drivers/net/tap/rte_eth_tap.c +0
-0@@ -760,6 +763,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return 0; }drivers/net/tap/rte_eth_tap.c tap_mtu_set(struct rte_eth_dev *dev, uint16_t · line 775
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +}Can we just add the code to grab the ptype value instead of just saying not supported.
Quoted 4 lines
The original code would just return an error from ethdev correct, what was wrong with that one. I would like to see the tap PMD just return the ptype would that not be more useful?
tap PMD depends on the rte_net_get_ptype(), which code may change in the future to support more packet types. Those changes would then need to be reflected on the tap PMD, to be consistent.
I reported only RTE_PTYPE_UNKNOWN to avoid keeping a tight sync with the rte_net library. As we're allowed to be more precise in the packet types we actually set, compared to those we declare as supported, I thought it best.
Would you indeed rather we copied all currently supported packet types from rte_net to tap_dev_supported_ptypes_get()?
Regards,
Pascal
Quoted 19 lines
Quoted 11 lines
drivers/net/tap/rte_eth_tap.c +2
-0+static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -784,6 +798,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, };Quoted 4 lines
static int
Signature · 1 line
2.8.0.rc0Regards,
Keith
Re: [PATCH 5/6] net/tap: add packet type management
Quoted 80 lines · Pascal Mazon
Quoted 65 lines · Keith
Quoted 51 lines
On Mar 3, 2017, at 3:46 AM, Pascal Mazon <[email protected]> wrote:
Advertize
RTE_PTYPE_UNKNOWNsince tap does not report any packet type.Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 15 +++++++++++++++2 files changed, 16 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
6aa11874e2bc..7f3f4d661dd7100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini(quoted diff) +0
-0@@ -13,6 +13,7 @@ MTU update = YMulticast MAC filter = Y
Speed capabilities = Y
Unicast MAC filter = Y
+Packet type parsing = YOther kdrv = Y ARMv7 = Y ARMv8 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex64b84cd76321..e4af36a6d142100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +3
-0@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h> @@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;drivers/net/tap/rte_eth_tap.c +0
-0@@ -760,6 +763,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return 0; }drivers/net/tap/rte_eth_tap.c tap_mtu_set(struct rte_eth_dev *dev, uint16_t · line 775
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +}Can we just add the code to grab the ptype value instead of just saying not supported.
Quoted 4 lines
The original code would just return an error from ethdev correct, what was wrong with that one. I would like to see the tap PMD just return the ptype would that not be more useful?
tap PMD depends on the
rte_net_get_ptype(), which code may change in the future to support more packet types. Those changes would then need to be reflected on the tap PMD, to be consistent.
Quoted 7 lines
I reported only
RTE_PTYPE_UNKNOWNto avoid keeping a tight sync with therte_netlibrary. As we're allowed to be more precise in the packet types we actually set, compared to those we declare as supported, I thought it best.Would you indeed rather we copied all currently supported packet types from
rte_nettotap_dev_supported_ptypes_get()?
I see your point here, it not reasonable to copy all of the ptypes from rte_net to here ignore my comment.
Quoted 24 lines
Regards,
PascalQuoted 19 lines
Quoted 11 lines
drivers/net/tap/rte_eth_tap.c +2
-0+static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -784,6 +798,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, };Quoted 4 lines
static int
Signature · 1 line
2.8.0.rc0Regards,
Keith
Regards,
Keith
PATCH 6/6 net/tap: add flow control management
In reply to Pascal MazonA tap netdevice does not support flow control; ensure nothing but RTE_FC_NONE mode can be set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -14,6 +14,7 @@ Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Packet type parsing = Y +Flow control = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +19 -0
@@ -774,6 +774,23 @@ tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static int +tap_flow_ctrl_get(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ + fc_conf->mode =RTE_FC_NONE ; +return 0 ; +} + +static int +tap_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ +if (fc_conf->mode !=RTE_FC_NONE ) +return -ENOTSUP ; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -784,6 +801,8 @@ static const struct eth_dev_ops ops = { .tx_queue_setup = tap_tx_queue_setup, .rx_queue_release = tap_rx_queue_release, .tx_queue_release = tap_tx_queue_release, + .flow_ctrl_get = tap_flow_ctrl_get, + .flow_ctrl_set = tap_flow_ctrl_set, .link_update = tap_link_update, .dev_set_link_up = tap_link_set_up, .dev_set_link_down = tap_link_set_down,
Signature · 1 line
2.8.0.rc0
v2 cover net/tap: add additional management ops
In reply to Pascal MazonAdd a few eth_dev ops to the tap PMD for completeness. We want it to behave as much as possible as a standard PMD.
v2 change:
- use snprintf in tap_mtu set
Pascal Mazon (6):
net/tap: add MAC address management ops
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add MTU management
net/tap: add packet type management
net/tap: add flow control management
doc/guides/nics/features/tap.ini | 6 ++ drivers/net/tap/rte_eth_tap.c | 207 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 200 insertions(+), 13 deletions(-)
Signature · 1 line
2.8.0.rc0
PATCH v2 1/6 net/tap: add MAC address management ops
Set a random MAC address when probing the device, as to not leave an empty MAC in pmd->eth_addr.
This MAC will be set on the tap netdevice as soon as it's been created using tun_alloc(). As the tap_mac_add() function depend on the fd in the first rxq, move code from tun_alloc() to tap_setup_queue(), after it's been set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 88 ++++++++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 13 deletions(-)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +75 -13
142 lines not on this page · raw message
Signature · 1 line
2.8.0.rc0
PATCH v2 2/6 net/tap: add speed capabilities
In reply to Pascal MazonTap PMD is flexible, it supports any speed.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ; + +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Signature · 1 line
2.8.0.rc0
PATCH v2 3/6 net/tap: add multicast addresses management
In reply to Pascal MazonA tap netdevice actually receives every packet, without any filtering whatsoever. There is no need for any multicast address registration to receive multicast packets.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y
drivers/net/tap/rte_eth_tap.c +13 -0
@@ -712,6 +712,18 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,return 0 ; } +static int +tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mc_addr_set __rte_unused, + uint32_t nb_mc_addr __rte_unused) +{ +/* +* Nothing to do actually: the tap has no filtering whatsoever, every +* packet is received. +*/ +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -732,6 +744,7 @@ static const struct eth_dev_ops ops = { .mac_addr_remove = tap_mac_remove, .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, + .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v2 4/6 net/tap: add MTU management
In reply to Pascal MazonThe MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y
drivers/net/tap/rte_eth_tap.c +37 -0
@@ -724,6 +724,42 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; +int err, s; + + s =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (s <0 ) { +RTE_LOG (ERR ,PMD , +"Unable to get a socket for %s to set flags: %s\n" , + pmd->name,strerror (errno)); +return -1 ; + } +memset (&ifr,0 ,sizeof (ifr)); +strncpy (ifr.ifr_name, pmd->name,IFNAMSIZ ); + err =ioctl (s,SIOCGIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to get %s device MTU: %s\n" , + pmd->name,strerror (errno)); +close (s); +return -1 ; + } + ifr.ifr_mtu = mtu; + err =ioctl (s,SIOCSIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to set %s mtu %d: %s\n" , + pmd->name, mtu,strerror (errno)); +close (s); +return -1 ; + } +close (s); + dev->data->mtu = mtu; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -745,6 +781,7 @@ static const struct eth_dev_ops ops = { .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, .set_mc_addr_list = tap_set_mc_addr_list, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v2 5/6 net/tap: add packet type management
In reply to Pascal MazonAdvertize RTE_PTYPE_UNKNOWN since tap does not report any packet type.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +15 -0
@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
@@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;
@@ -760,6 +763,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -784,6 +798,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Signature · 1 line
2.8.0.rc0
PATCH v2 6/6 net/tap: add flow control management
In reply to Pascal MazonA tap netdevice does not support flow control; ensure nothing but RTE_FC_NONE mode can be set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -14,6 +14,7 @@ Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Packet type parsing = Y +Flow control = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +19 -0
@@ -774,6 +774,23 @@ tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static int +tap_flow_ctrl_get(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ + fc_conf->mode =RTE_FC_NONE ; +return 0 ; +} + +static int +tap_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ +if (fc_conf->mode !=RTE_FC_NONE ) +return -ENOTSUP ; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -784,6 +801,8 @@ static const struct eth_dev_ops ops = { .tx_queue_setup = tap_tx_queue_setup, .rx_queue_release = tap_rx_queue_release, .tx_queue_release = tap_tx_queue_release, + .flow_ctrl_get = tap_flow_ctrl_get, + .flow_ctrl_set = tap_flow_ctrl_set, .link_update = tap_link_update, .dev_set_link_up = tap_link_set_up, .dev_set_link_down = tap_link_set_down,
Signature · 1 line
2.8.0.rc0
v3 cover net/tap: add additional management ops
In reply to Pascal MazonAdd a few eth_dev ops to the tap PMD for completeness. We want it to behave as much as possible as a standard PMD.
v2 change:
- use snprintf in tap_mtu set
v3 change:
- call tap_mac_set() only once in tap_setup_queue()
Pascal Mazon (6):
net/tap: add MAC address management ops
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add MTU management
net/tap: add packet type management
net/tap: add flow control management
doc/guides/nics/features/tap.ini | 6 ++ drivers/net/tap/rte_eth_tap.c | 216 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 209 insertions(+), 13 deletions(-)
Signature · 1 line
2.8.0.rc0
v4 cover net/tap: add additional management ops
Add a few eth_dev ops to the tap PMD for completeness. We want it to behave as much as possible as a standard PMD.
v2 change:
- use snprintf in tap_mtu set
v3 change:
- call tap_mac_set() only once in tap_setup_queue()
v4 changes:
- use new tap_ioctl function for shared behavior between ops
- update supported packet types
- remove IFF_NOARP flag from link status change
- sync desired MTU to both remote and tap netdevices
- remove support for mac_add and mac_remove ops
Pascal Mazon (8):
net/tap: remove wrong IFF_NOARP flags
net/tap: refactor ioctl calls
net/tap: add MAC address management
net/tap: add MTU management
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add packet type management
net/tap: add flow control management
doc/guides/nics/features/tap.ini | 6 + drivers/net/tap/rte_eth_tap.c | 255 +++++++++++++++++++++++++++++++-------- 2 files changed, 214 insertions(+), 47 deletions(-)
Signature · 1 line
2.8.0.rc0
PATCH v4 1/8 net/tap: remove wrong IFF_NOARP flags
There is no reason not to support ARP on a tap netdevice. Focus on IFF_UP when a link status change is required.
--- drivers/net/tap/rte_eth_tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +2 -2
@@ -327,7 +327,7 @@ tap_link_set_down(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_DOWN ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,0 ); +return tap_link_set_flags (pmd,IFF_UP ,0 ); } static int
@@ -336,7 +336,7 @@ tap_link_set_up(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_UP ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,1 ); +return tap_link_set_flags (pmd,IFF_UP ,1 ); } static int
Signature · 1 line
2.8.0.rc0
PATCH v4 2/8 net/tap: refactor ioctl calls
In reply to Pascal MazonCreate a socket for ioctl at tap device creation instead of opening it and closing it every call to tap_link_set_flags().
Use a common tap_ioctl() function that can be extended for various uses (such as MTU change, MAC address change, ...).
--- drivers/net/tap/rte_eth_tap.c | 90 +++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 42 deletions(-)
drivers/net/tap/rte_eth_tap.c +48 -42
@@ -107,6 +107,7 @@ struct pmd_internals {struct ether_addr eth_addr;/* Mac address of the device port */ int if_index;/* IF_INDEX for the port */ +int ioctl_sock;/* socket for ioctl calls */ struct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES ];/* List of RX queues */ struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES ];/* List of TX queues */
@@ -280,63 +281,55 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) }static int -tap_link_set_flags (struct pmd_internals *pmd,short flags,int add) +tap_ioctl (struct pmd_internals *pmd,unsigned long request, +struct ifreq *ifr,int set) { -struct ifreq ifr; -int err, s; - -/* -* An AF_INET/DGRAM socket is needed for -* SIOCGIFFLAGS/SIOCSIFFLAGS, using fd won't work. -*/ - s =socket (AF_INET ,SOCK_DGRAM ,0 ); -if (s <0 ) { -RTE_LOG (ERR ,PMD , -"Unable to get a socket to set flags: %s\n" , -strerror (errno)); -return -1 ; - } -memset (&ifr,0 ,sizeof (ifr)); -snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); - err =ioctl (s,SIOCGIFFLAGS , &ifr); -if (err <0 ) { -RTE_LOG (WARNING ,PMD ,"Unable to get %s device flags: %s\n" , - pmd->name,strerror (errno)); -close (s); -return -1 ; - } -if (add) - ifr.ifr_flags |= flags; -else - ifr.ifr_flags &= ~flags; - err =ioctl (s,SIOCSIFFLAGS , &ifr); -if (err <0 ) { -RTE_LOG (WARNING ,PMD ,"Unable to %s flags 0x%x: %s\n" , - add ?"set" :"unset" , flags,strerror (errno)); -close (s); -return -1 ; - } -close (s); +short req_flags = ifr->ifr_flags; +snprintf (ifr->ifr_name,IFNAMSIZ ,"%s" , pmd->name); +switch (request) { +case SIOCSIFFLAGS : +/* fetch current flags to leave other flags untouched */ +if (ioctl (pmd->ioctl_sock,SIOCGIFFLAGS , ifr) <0 ) + goto error; +if (set) + ifr->ifr_flags |= req_flags; +else + ifr->ifr_flags &= ~req_flags; +break ; +default : +RTE_LOG (WARNING ,PMD ,"%s: ioctl() called with wrong arg\n" , + pmd->name); +return -EINVAL ; + } +if (ioctl (pmd->ioctl_sock, request, ifr) <0 ) + goto error;return 0 ; + +error: +RTE_LOG (ERR ,PMD ,"%s: ioctl(%lu) failed with error: %s\n" , + ifr->ifr_name, request,strerror (errno)); +return -errno; }static int tap_link_set_down (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_UP }; dev->data->dev_link.link_status =ETH_LINK_DOWN ; -return tap_link_set_flags (pmd,IFF_UP ,0 ); +return tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); }static int tap_link_set_up (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_UP }; dev->data->dev_link.link_status =ETH_LINK_UP ; -return tap_link_set_flags (pmd,IFF_UP ,1 ); +return tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); } static int
@@ -470,36 +463,40 @@ static void tap_promisc_enable(struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_PROMISC }; dev->data->promiscuous =1 ; -tap_link_set_flags (pmd,IFF_PROMISC ,1 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); }static void tap_promisc_disable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_PROMISC }; dev->data->promiscuous =0 ; -tap_link_set_flags (pmd,IFF_PROMISC ,0 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); }static void tap_allmulti_enable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_ALLMULTI }; dev->data->all_multicast =1 ; -tap_link_set_flags (pmd,IFF_ALLMULTI ,1 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); }static void tap_allmulti_disable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_ALLMULTI }; dev->data->all_multicast =0 ; -tap_link_set_flags (pmd,IFF_ALLMULTI ,0 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); } static int
@@ -675,6 +672,14 @@ eth_dev_tap_create(const char *name, char *tap_name) pmd->nb_queues =RTE_PMD_TAP_MAX_QUEUES ; + pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (pmd->ioctl_sock ==-1 ) { +RTE_LOG (ERR ,PMD , +"TAP Unable to get a socket for management: %s\n" , +strerror (errno)); + goto error_exit; + } +/* Setup some default values */ data->dev_private = pmd; data->port_id = dev->data->port_id;
@@ -817,6 +822,7 @@ rte_pmd_tap_remove(const char *name)if (internals->rxq[i].fd !=-1 )close (internals->rxq[i].fd); +close (internals->ioctl_sock);rte_free (eth_dev->data->dev_private);rte_free (eth_dev->data);
Signature · 1 line
2.8.0.rc0
PATCH v4 3/8 net/tap: add MAC address management
In reply to Pascal MazonAs soon as the netdevice is created, update pmd->mac_addr with its actual MAC address.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +33 -6
@@ -113,6 +113,10 @@ struct pmd_internals {struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES ];/* List of TX queues */ }; +static int +tap_ioctl (struct pmd_internals *pmd,unsigned long request, +struct ifreq *ifr,int set); +/* Tun/Tap allocation routine * * name is the number of the interface to use, unless NULL to take the host
@@ -178,13 +182,12 @@ tun_alloc(struct pmd_internals *pmd, uint16_t qid) }if (qid ==0 ) { -if (ioctl (fd,SIOCGIFHWADDR , &ifr) ==-1 ) { -RTE_LOG (ERR ,PMD ,"ioctl failed (SIOCGIFHWADDR) (%s)\n" , - ifr.ifr_name); - goto error; - } +struct ifreq ifr; -rte_memcpy (&pmd->eth_addr, ifr.ifr_hwaddr.sa_data,ETH_ALEN ); +if (tap_ioctl (pmd,SIOCGIFHWADDR , &ifr,0 ) <0 ) + goto error; +rte_memcpy (&pmd->eth_addr, ifr.ifr_hwaddr.sa_data, +ETHER_ADDR_LEN ); }return fd;
@@ -297,6 +300,9 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,else ifr->ifr_flags &= ~req_flags;break ; +case SIOCGIFHWADDR : +case SIOCSIFHWADDR : +break ;default :RTE_LOG (WARNING ,PMD ,"%s: ioctl() called with wrong arg\n" , pmd->name);
@@ -499,6 +505,26 @@ tap_allmulti_disable(struct rte_eth_dev *dev)tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); } + +static void +tap_mac_set (struct rte_eth_dev *dev,struct ether_addr *mac_addr) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; + +if (is_zero_ether_addr (mac_addr)) { +RTE_LOG (ERR ,PMD ,"%s: can't set an empty MAC address\n" , + dev->data->name); +return ; + } + + ifr.ifr_hwaddr.sa_family =AF_LOCAL ; +rte_memcpy (ifr.ifr_hwaddr.sa_data, mac_addr,ETHER_ADDR_LEN ); +if (tap_ioctl (pmd,SIOCSIFHWADDR , &ifr,1 ) <0 ) +return ; +rte_memcpy (&pmd->eth_addr, mac_addr,ETHER_ADDR_LEN ); +} + static int tap_setup_queue(struct rte_eth_dev *dev, struct pmd_internals *internals,
@@ -633,6 +659,7 @@ static const struct eth_dev_ops ops = { .promiscuous_disable = tap_promisc_disable, .allmulticast_enable = tap_allmulti_enable, .allmulticast_disable = tap_allmulti_disable, + .mac_addr_set = tap_mac_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v4 4/8 net/tap: add MTU management
In reply to Pascal MazonThe MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
As a new rte_eth_dev_data is allocated during tap device init, ensure it is set again dev->data->mtu.
Once the actual netdevice is created via tun_alloc(), make sure to apply the desired MTU to the netdevice.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +26 -0
@@ -302,6 +302,7 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,break ;case SIOCGIFHWADDR :case SIOCSIFHWADDR : +case SIOCSIFMTU :break ;default : RTE_LOG(WARNING, PMD, "%s: ioctl() called with wrong arg\n",
@@ -547,6 +548,15 @@ tap_setup_queue(struct rte_eth_dev *dev, pmd->name, qid);return -1 ; } +if (qid ==0 ) { +struct ifreq ifr; + + ifr.ifr_mtu = dev->data->mtu; +if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ) <0 ) { +close (fd); +return -1 ; + } + } } }
@@ -642,6 +652,20 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_mtu = mtu }; +int err =0 ; + + err =tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ); +if (!err) + dev->data->mtu = mtu; + +return err; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -660,6 +684,7 @@ static const struct eth_dev_ops ops = { .allmulticast_enable = tap_allmulti_enable, .allmulticast_disable = tap_allmulti_disable, .mac_addr_set = tap_mac_set, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
@@ -710,6 +735,7 @@ eth_dev_tap_create(const char *name, char *tap_name)/* Setup some default values */ data->dev_private = pmd; data->port_id = dev->data->port_id; + data->mtu = dev->data->mtu; data->dev_flags =RTE_ETH_DEV_DETACHABLE ; data->kdrv =RTE_KDRV_NONE ; data->drv_name = pmd_tap_drv.driver.name;
Signature · 1 line
2.8.0.rc0
PATCH v4 5/8 net/tap: add speed capabilities
In reply to Pascal MazonTap PMD is flexible, it supports any speed.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -10,6 +10,7 @@ Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y MTU update = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -359,6 +359,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ; + +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -371,6 +405,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Signature · 1 line
2.8.0.rc0
PATCH v4 6/8 net/tap: add multicast addresses management
In reply to Pascal MazonA tap netdevice actually receives every packet, without any filtering whatsoever. There is no need for any multicast address registration to receive multicast packets.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -10,6 +10,7 @@ Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y MTU update = Y +Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y
drivers/net/tap/rte_eth_tap.c +13 -0
@@ -701,6 +701,18 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return err; } +static int +tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mc_addr_set __rte_unused, + uint32_t nb_mc_addr __rte_unused) +{ +/* +* Nothing to do actually: the tap has no filtering whatsoever, every +* packet is received. +*/ +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -720,6 +732,7 @@ static const struct eth_dev_ops ops = { .allmulticast_disable = tap_allmulti_disable, .mac_addr_set = tap_mac_set, .mtu_set = tap_mtu_set, + .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v4 7/8 net/tap: add packet type management
In reply to Pascal MazonAdvertize packet types supported by the librte_net.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
@@ -228,6 +229,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;
@@ -713,6 +716,37 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER_VLAN , +RTE_PTYPE_INNER_L2_ETHER_QINQ , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV4_EXT , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L3_IPV6_EXT , +RTE_PTYPE_INNER_L4_FRAG , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_L2_ETHER_VLAN , +RTE_PTYPE_L2_ETHER_QINQ , +RTE_PTYPE_L3_IPV4 , +RTE_PTYPE_L3_IPV4_EXT , +RTE_PTYPE_L3_IPV6_EXT , +RTE_PTYPE_L3_IPV6 , +RTE_PTYPE_L4_FRAG , +RTE_PTYPE_L4_UDP , +RTE_PTYPE_L4_TCP , +RTE_PTYPE_L4_SCTP , + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -735,6 +769,7 @@ static const struct eth_dev_ops ops = { .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Signature · 1 line
2.8.0.rc0
Re: [PATCH v4 7/8] net/tap: add packet type management
Quoted 3 lines · Pascal Mazon
Advertize packet types supported by the
librte_net.Signed-off-by Pascal Mazon <[email protected]>
<...>
Review pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 233
Quoted 9 lines
#include <
sys/types.h>
#include <sys/stat.h>(quoted diff) +2
-0@@ -228,6 +229,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type = rte_net_get_ptype(mbuf, NULL, + RTE_PTYPE_ALL_MASK);
This breaks shared library build [1], now librte_net also needs to be linked against PMD, this can be done easily by adding library as dependency [2] to PMD.
[1]
rte_eth_tap.o: In function `pmd_rx_burst':
.../drivers/net/tap/rte_eth_tap.c:(.text+0x863): undefined reference to `rte_net_get_ptype'
[2]
drivers/net/tap/Makefile +1 -0
@@ -53,5 +53,6 @@ DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_mempool DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_kvargs +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_net include $(RTE_SDK)/mk/rte.lib.mk
Re: [PATCH v4 7/8] net/tap: add packet type management
Quoted 39 lines · On Wed, 15 Mar 2017 13:35:44 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 3 lines · Pascal Mazon
Advertize packet types supported by the
librte_net.Signed-off-by Pascal Mazon <[email protected]><...>
Review pmd_rx_burst(void *queue, struct rte_mbuf · line 234
Quoted 10 lines
#include <
sys/types.h>
#include <sys/stat.h>(quoted diff) +2
-0@@ -228,6 +229,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type = rte_net_get_ptype(mbuf, NULL, + RTE_PTYPE_ALL_MASK);This breaks shared library build [1], now
librte_netalso needs to be linked against PMD, this can be done easily by adding library as dependency [2] to PMD.[1]
rte_eth_tap.o: In function `pmd_rx_burst':
.../drivers/net/tap/rte_eth_tap.c:(.text+0x863): undefined reference to `rte_net_get_ptype'[2]
drivers/net/tap/Makefile +0
-0@@ -53,5 +53,6 @@ DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=
lib/librte_mbufDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_mempoolDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_etherDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_kvargs+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_net
Quoted 1 line
include $(RTE_SDK)/mk/rte.lib.mk
Indeed!
I'll fix that and send a new version (rebased on the latest next-net, following adrien's changes to tap PMD).
Regards,
Pascal
Re: [PATCH v4 7/8] net/tap: add packet type management
Quoted 42 lines · Pascal Mazon
Quoted 39 lines · On Wed, 15 Mar 2017 13:35:44 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 3 lines · Pascal Mazon
Advertize packet types supported by the
librte_net.Signed-off-by Pascal Mazon <[email protected]><...>
Review pmd_rx_burst(void *queue, struct rte_mbuf · line 234
Quoted 10 lines
#include <
sys/types.h>
#include <sys/stat.h>(quoted diff) +2
-0@@ -228,6 +229,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type = rte_net_get_ptype(mbuf, NULL, + RTE_PTYPE_ALL_MASK);This breaks shared library build [1], now
librte_netalso needs to be linked against PMD, this can be done easily by adding library as dependency [2] to PMD.[1]
rte_eth_tap.o: In function `pmd_rx_burst':
.../drivers/net/tap/rte_eth_tap.c:(.text+0x863): undefined reference to `rte_net_get_ptype'[2]
drivers/net/tap/Makefile +0
-0@@ -53,5 +53,6 @@ DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=
lib/librte_mbufDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_mempoolDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_etherDEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_kvargs+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) +=lib/librte_net
Quoted 6 lines
Quoted 1 line
include $(RTE_SDK)/mk/rte.lib.mk
Indeed!
I'll fix that and send a new version (rebased on the latest next-net, following adrien's changes to tap PMD).
Can you also rebase tap rte_flow one [1], after this one please? Because that set effected from both this one and Adrien's changes.
[1]
http://dpdk.org/dev/patchwork/patch/21757/ [4 patches]
Thanks,
ferruh
Quoted 4 lines
Regards,
Pascal
Re: [PATCH v4 7/8] net/tap: add packet type management
In reply to Pascal MazonQuoted 3 lines · Pascal Mazon
Advertize packet types supported by the
librte_net.Signed-off-by Pascal Mazon <[email protected]>
<...>
Quoted 17 lines
drivers/net/tap/rte_eth_tap.c +16
-0+static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER_VLAN , +RTE_PTYPE_INNER_L2_ETHER_QINQ , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV4_EXT , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L3_IPV6_EXT , +RTE_PTYPE_INNER_L4_FRAG , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_L2_ETHER ,
drivers/net/tap/rte_eth_tap.c tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, · line 744
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+RTE_PTYPE_L2_ETHER_VLAN , +RTE_PTYPE_L2_ETHER_QINQ , +RTE_PTYPE_L3_IPV4 , +RTE_PTYPE_L3_IPV4_EXT , +RTE_PTYPE_L3_IPV6_EXT , +RTE_PTYPE_L3_IPV6 , +RTE_PTYPE_L4_FRAG , +RTE_PTYPE_L4_UDP , +RTE_PTYPE_L4_TCP , + RTE_PTYPE_L4_SCTP,
Not for this patch, but it can be good if librte_net exports a macro that lists rte_net_get_ptype() supported types.
PATCH v4 8/8 net/tap: add flow control management
In reply to Pascal MazonA tap netdevice does not support flow control; ensure nothing but RTE_FC_NONE mode can be set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -14,6 +14,7 @@ Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Packet type parsing = Y +Flow control = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +19 -0
@@ -747,6 +747,23 @@ tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static int +tap_flow_ctrl_get(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ + fc_conf->mode =RTE_FC_NONE ; +return 0 ; +} + +static int +tap_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ +if (fc_conf->mode !=RTE_FC_NONE ) +return -ENOTSUP ; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -757,6 +774,8 @@ static const struct eth_dev_ops ops = { .tx_queue_setup = tap_tx_queue_setup, .rx_queue_release = tap_rx_queue_release, .tx_queue_release = tap_tx_queue_release, + .flow_ctrl_get = tap_flow_ctrl_get, + .flow_ctrl_set = tap_flow_ctrl_set, .link_update = tap_link_update, .dev_set_link_up = tap_link_set_up, .dev_set_link_down = tap_link_set_down,
Signature · 1 line
2.8.0.rc0
Quoted 16 lines · Pascal Mazon
Add a few
eth_devops to the tap PMD for completeness. We want it to behave as much as possible as a standard PMD.v2 change:
- use snprintf intap_mtusetv3 change:
- calltap_mac_set()only once intap_setup_queue()v4 changes:
- use newtap_ioctlfunction for shared behavior between ops
- update supported packet types
- removeIFF_NOARPflag from link status change
- sync desired MTU to both remote and tap netdevices
- remove support formac_addandmac_removeops
Quoted 9 lines
Pascal Mazon (8):
net/tap: remove wrongIFF_NOARPflags
net/tap: refactor ioctl calls
net/tap: add MAC address management
net/tap: add MTU management
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add packet type management
net/tap: add flow control management
Except from missing librte_net dependency, patchset looks good to me,
Series Reviewed-by: Ferruh Yigit <[email protected]>
v5 cover net/tap: add additional management ops
In reply to Pascal Mazonv2 change:
- use snprintf in tap_mtu set
v3 change:
- call tap_mac_set() only once in tap_setup_queue()
v4 changes:
- use new tap_ioctl function for shared behavior between ops
- update supported packet types
- remove IFF_NOARP flag from link status change
- sync desired MTU to both remote and tap netdevices
- remove support for mac_add and mac_remove ops
v5 changes:
- rebase after adrien's patches on Tx poll and Rx signaling
- add dependency to librte_net for packet type
Pascal Mazon (8):
net/tap: remove wrong IFF_NOARP flags
net/tap: refactor ioctl calls
net/tap: add MAC address management
net/tap: add MTU management
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add packet type management
net/tap: add flow control management
doc/guides/nics/features/tap.ini | 6 + drivers/net/tap/Makefile | 1 + drivers/net/tap/rte_eth_tap.c | 255 +++++++++++++++++++++++++++++++-------- 3 files changed, 215 insertions(+), 47 deletions(-)
Signature · 1 line
2.8.0.rc0
PATCH v5 1/8 net/tap: remove wrong IFF_NOARP flags
There is no reason not to support ARP on a tap netdevice. Focus on IFF_UP when a link status change is required.
--- drivers/net/tap/rte_eth_tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +2 -2
@@ -375,7 +375,7 @@ tap_link_set_down(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_DOWN ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,0 ); +return tap_link_set_flags (pmd,IFF_UP ,0 ); } static int
@@ -384,7 +384,7 @@ tap_link_set_up(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_UP ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,1 ); +return tap_link_set_flags (pmd,IFF_UP ,1 ); } static int
Signature · 1 line
2.8.0.rc0
Re: [PATCH v5 1/8] net/tap: remove wrong IFF_NOARP flags
Quoted 9 lines · Pascal Mazon
There is no reason not to support ARP on a tap netdevice. Focus on
IFF_UPwhen a link status change is required.Fixes f457b472b1f2 ("net/tap: add link up and down operations")Signed-off-by Pascal Mazon <[email protected]>Reviewed-by Ferruh Yigit <[email protected]>
Quoted 25 lines
---
drivers/net/tap/rte_eth_tap.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/tap/rte_eth_tap.c +1
-1@@ -375,7 +375,7 @@ tap_link_set_down(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_DOWN ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,0 ); +return tap_link_set_flags (pmd,IFF_UP ,0 ); }static int
drivers/net/tap/rte_eth_tap.c +1
-1@@ -384,7 +384,7 @@ tap_link_set_up(struct rte_eth_dev *dev)struct pmd_internals *pmd = dev->data->dev_private; dev->data->dev_link.link_status =ETH_LINK_UP ; -return tap_link_set_flags (pmd,IFF_UP |IFF_NOARP ,1 ); +return tap_link_set_flags (pmd,IFF_UP ,1 ); }
Quoted 4 lines
static int
Signature · 1 line
2.8.0.rc0
Regards,
Keith
PATCH v5 2/8 net/tap: refactor ioctl calls
In reply to Pascal MazonCreate a socket for ioctl at tap device creation instead of opening it and closing it every call to tap_link_set_flags().
Use a common tap_ioctl() function that can be extended for various uses (such as MTU change, MAC address change, ...).
--- drivers/net/tap/rte_eth_tap.c | 90 +++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 42 deletions(-)
drivers/net/tap/rte_eth_tap.c +48 -42
@@ -114,6 +114,7 @@ struct pmd_internals {struct ether_addr eth_addr;/* Mac address of the device port */ int if_index;/* IF_INDEX for the port */ +int ioctl_sock;/* socket for ioctl calls */ struct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES ];/* List of RX queues */ struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES ];/* List of TX queues */
@@ -328,63 +329,55 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) }static int -tap_link_set_flags (struct pmd_internals *pmd,short flags,int add) +tap_ioctl (struct pmd_internals *pmd,unsigned long request, +struct ifreq *ifr,int set) { -struct ifreq ifr; -int err, s; - -/* -* An AF_INET/DGRAM socket is needed for -* SIOCGIFFLAGS/SIOCSIFFLAGS, using fd won't work. -*/ - s =socket (AF_INET ,SOCK_DGRAM ,0 ); -if (s <0 ) { -RTE_LOG (ERR ,PMD , -"Unable to get a socket to set flags: %s\n" , -strerror (errno)); -return -1 ; - } -memset (&ifr,0 ,sizeof (ifr)); -snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); - err =ioctl (s,SIOCGIFFLAGS , &ifr); -if (err <0 ) { -RTE_LOG (WARNING ,PMD ,"Unable to get %s device flags: %s\n" , - pmd->name,strerror (errno)); -close (s); -return -1 ; - } -if (add) - ifr.ifr_flags |= flags; -else - ifr.ifr_flags &= ~flags; - err =ioctl (s,SIOCSIFFLAGS , &ifr); -if (err <0 ) { -RTE_LOG (WARNING ,PMD ,"Unable to %s flags 0x%x: %s\n" , - add ?"set" :"unset" , flags,strerror (errno)); -close (s); -return -1 ; - } -close (s); +short req_flags = ifr->ifr_flags; +snprintf (ifr->ifr_name,IFNAMSIZ ,"%s" , pmd->name); +switch (request) { +case SIOCSIFFLAGS : +/* fetch current flags to leave other flags untouched */ +if (ioctl (pmd->ioctl_sock,SIOCGIFFLAGS , ifr) <0 ) + goto error; +if (set) + ifr->ifr_flags |= req_flags; +else + ifr->ifr_flags &= ~req_flags; +break ; +default : +RTE_LOG (WARNING ,PMD ,"%s: ioctl() called with wrong arg\n" , + pmd->name); +return -EINVAL ; + } +if (ioctl (pmd->ioctl_sock, request, ifr) <0 ) + goto error;return 0 ; + +error: +RTE_LOG (ERR ,PMD ,"%s: ioctl(%lu) failed with error: %s\n" , + ifr->ifr_name, request,strerror (errno)); +return -errno; }static int tap_link_set_down (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_UP }; dev->data->dev_link.link_status =ETH_LINK_DOWN ; -return tap_link_set_flags (pmd,IFF_UP ,0 ); +return tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); }static int tap_link_set_up (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_UP }; dev->data->dev_link.link_status =ETH_LINK_UP ; -return tap_link_set_flags (pmd,IFF_UP ,1 ); +return tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); } static int
@@ -518,36 +511,40 @@ static void tap_promisc_enable(struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_PROMISC }; dev->data->promiscuous =1 ; -tap_link_set_flags (pmd,IFF_PROMISC ,1 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); }static void tap_promisc_disable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_PROMISC }; dev->data->promiscuous =0 ; -tap_link_set_flags (pmd,IFF_PROMISC ,0 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); }static void tap_allmulti_enable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_ALLMULTI }; dev->data->all_multicast =1 ; -tap_link_set_flags (pmd,IFF_ALLMULTI ,1 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,1 ); }static void tap_allmulti_disable (struct rte_eth_dev *dev) {struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_flags =IFF_ALLMULTI }; dev->data->all_multicast =0 ; -tap_link_set_flags (pmd,IFF_ALLMULTI ,0 ); +tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); } static int
@@ -724,6 +721,14 @@ eth_dev_tap_create(const char *name, char *tap_name) pmd->nb_queues =RTE_PMD_TAP_MAX_QUEUES ; + pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (pmd->ioctl_sock ==-1 ) { +RTE_LOG (ERR ,PMD , +"TAP Unable to get a socket for management: %s\n" , +strerror (errno)); + goto error_exit; + } +/* Setup some default values */ data->dev_private = pmd; data->port_id = dev->data->port_id;
@@ -866,6 +871,7 @@ rte_pmd_tap_remove(const char *name)if (internals->rxq[i].fd !=-1 )close (internals->rxq[i].fd); +close (internals->ioctl_sock);rte_free (eth_dev->data->dev_private);rte_free (eth_dev->data);
Signature · 1 line
2.8.0.rc0
PATCH v5 3/8 net/tap: add MAC address management
In reply to Pascal MazonAs soon as the netdevice is created, update pmd->mac_addr with its actual MAC address.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +33 -6
@@ -127,6 +127,10 @@ tap_trigger_cb(int sig __rte_unused) tap_trigger = (tap_trigger +1 ) |0x80000000 ; } +static int +tap_ioctl (struct pmd_internals *pmd,unsigned long request, +struct ifreq *ifr,int set); +/* Tun/Tap allocation routine * * name is the number of the interface to use, unless NULL to take the host
@@ -229,13 +233,12 @@ tun_alloc(struct pmd_internals *pmd, uint16_t qid) }if (qid ==0 ) { -if (ioctl (fd,SIOCGIFHWADDR , &ifr) ==-1 ) { -RTE_LOG (ERR ,PMD ,"ioctl failed (SIOCGIFHWADDR) (%s)\n" , - ifr.ifr_name); - goto error; - } +struct ifreq ifr; -rte_memcpy (&pmd->eth_addr, ifr.ifr_hwaddr.sa_data,ETH_ALEN ); +if (tap_ioctl (pmd,SIOCGIFHWADDR , &ifr,0 ) <0 ) + goto error; +rte_memcpy (&pmd->eth_addr, ifr.ifr_hwaddr.sa_data, +ETHER_ADDR_LEN ); }return fd;
@@ -345,6 +348,9 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,else ifr->ifr_flags &= ~req_flags;break ; +case SIOCGIFHWADDR : +case SIOCSIFHWADDR : +break ;default :RTE_LOG (WARNING ,PMD ,"%s: ioctl() called with wrong arg\n" , pmd->name);
@@ -547,6 +553,26 @@ tap_allmulti_disable(struct rte_eth_dev *dev)tap_ioctl (pmd,SIOCSIFFLAGS , &ifr,0 ); } + +static void +tap_mac_set (struct rte_eth_dev *dev,struct ether_addr *mac_addr) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; + +if (is_zero_ether_addr (mac_addr)) { +RTE_LOG (ERR ,PMD ,"%s: can't set an empty MAC address\n" , + dev->data->name); +return ; + } + + ifr.ifr_hwaddr.sa_family =AF_LOCAL ; +rte_memcpy (ifr.ifr_hwaddr.sa_data, mac_addr,ETHER_ADDR_LEN ); +if (tap_ioctl (pmd,SIOCSIFHWADDR , &ifr,1 ) <0 ) +return ; +rte_memcpy (&pmd->eth_addr, mac_addr,ETHER_ADDR_LEN ); +} + static int tap_setup_queue(struct rte_eth_dev *dev, struct pmd_internals *internals,
@@ -682,6 +708,7 @@ static const struct eth_dev_ops ops = { .promiscuous_disable = tap_promisc_disable, .allmulticast_enable = tap_allmulti_enable, .allmulticast_disable = tap_allmulti_disable, + .mac_addr_set = tap_mac_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v5 4/8 net/tap: add MTU management
In reply to Pascal MazonThe MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
As a new rte_eth_dev_data is allocated during tap device init, ensure it is set again dev->data->mtu.
Once the actual netdevice is created via tun_alloc(), make sure to apply the desired MTU to the netdevice.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +26 -0
@@ -350,6 +350,7 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,break ;case SIOCGIFHWADDR :case SIOCSIFHWADDR : +case SIOCSIFMTU :break ;default : RTE_LOG(WARNING, PMD, "%s: ioctl() called with wrong arg\n",
@@ -595,6 +596,15 @@ tap_setup_queue(struct rte_eth_dev *dev, pmd->name, qid);return -1 ; } +if (qid ==0 ) { +struct ifreq ifr; + + ifr.ifr_mtu = dev->data->mtu; +if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ) <0 ) { +close (fd); +return -1 ; + } + } } }
@@ -691,6 +701,20 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr = { .ifr_mtu = mtu }; +int err =0 ; + + err =tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ); +if (!err) + dev->data->mtu = mtu; + +return err; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -709,6 +733,7 @@ static const struct eth_dev_ops ops = { .allmulticast_enable = tap_allmulti_enable, .allmulticast_disable = tap_allmulti_disable, .mac_addr_set = tap_mac_set, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
@@ -759,6 +784,7 @@ eth_dev_tap_create(const char *name, char *tap_name)/* Setup some default values */ data->dev_private = pmd; data->port_id = dev->data->port_id; + data->mtu = dev->data->mtu; data->dev_flags =RTE_ETH_DEV_DETACHABLE ; data->kdrv =RTE_KDRV_NONE ; data->drv_name = pmd_tap_drv.driver.name;
Signature · 1 line
2.8.0.rc0
PATCH v5 5/8 net/tap: add speed capabilities
In reply to Pascal MazonTap PMD is flexible, it supports any speed.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -10,6 +10,7 @@ Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y MTU update = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -407,6 +407,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ; + +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -419,6 +453,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Signature · 1 line
2.8.0.rc0
PATCH v5 6/8 net/tap: add multicast addresses management
In reply to Pascal MazonA tap netdevice actually receives every packet, without any filtering whatsoever. There is no need for any multicast address registration to receive multicast packets.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -10,6 +10,7 @@ Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y MTU update = Y +Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y
drivers/net/tap/rte_eth_tap.c +13 -0
@@ -750,6 +750,18 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return err; } +static int +tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mc_addr_set __rte_unused, + uint32_t nb_mc_addr __rte_unused) +{ +/* +* Nothing to do actually: the tap has no filtering whatsoever, every +* packet is received. +*/ +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -769,6 +781,7 @@ static const struct eth_dev_ops ops = { .allmulticast_disable = tap_allmulti_disable, .mac_addr_set = tap_mac_set, .mtu_set = tap_mtu_set, + .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v5 7/8 net/tap: add packet type management
In reply to Pascal MazonAdvertize packet types supported by the librte_net.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/Makefile | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/Makefile +1 -0
@@ -53,5 +53,6 @@ DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_mbuf DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_mempool DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_ether DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_kvargs +DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += lib/librte_net include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -38,6 +38,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
@@ -285,6 +286,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;
@@ -762,6 +765,37 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_INNER_L2_ETHER , +RTE_PTYPE_INNER_L2_ETHER_VLAN , +RTE_PTYPE_INNER_L2_ETHER_QINQ , +RTE_PTYPE_INNER_L3_IPV4 , +RTE_PTYPE_INNER_L3_IPV4_EXT , +RTE_PTYPE_INNER_L3_IPV6 , +RTE_PTYPE_INNER_L3_IPV6_EXT , +RTE_PTYPE_INNER_L4_FRAG , +RTE_PTYPE_INNER_L4_UDP , +RTE_PTYPE_INNER_L4_TCP , +RTE_PTYPE_INNER_L4_SCTP , +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_L2_ETHER_VLAN , +RTE_PTYPE_L2_ETHER_QINQ , +RTE_PTYPE_L3_IPV4 , +RTE_PTYPE_L3_IPV4_EXT , +RTE_PTYPE_L3_IPV6_EXT , +RTE_PTYPE_L3_IPV6 , +RTE_PTYPE_L4_FRAG , +RTE_PTYPE_L4_UDP , +RTE_PTYPE_L4_TCP , +RTE_PTYPE_L4_SCTP , + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -784,6 +818,7 @@ static const struct eth_dev_ops ops = { .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Signature · 1 line
2.8.0.rc0
PATCH v5 8/8 net/tap: add flow control management
In reply to Pascal MazonA tap netdevice does not support flow control; ensure nothing but RTE_FC_NONE mode can be set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -14,6 +14,7 @@ Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Packet type parsing = Y +Flow control = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +19 -0
@@ -796,6 +796,23 @@ tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static int +tap_flow_ctrl_get(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ + fc_conf->mode =RTE_FC_NONE ; +return 0 ; +} + +static int +tap_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ +if (fc_conf->mode !=RTE_FC_NONE ) +return -ENOTSUP ; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -806,6 +823,8 @@ static const struct eth_dev_ops ops = { .tx_queue_setup = tap_tx_queue_setup, .rx_queue_release = tap_rx_queue_release, .tx_queue_release = tap_tx_queue_release, + .flow_ctrl_get = tap_flow_ctrl_get, + .flow_ctrl_set = tap_flow_ctrl_set, .link_update = tap_link_update, .dev_set_link_up = tap_link_set_up, .dev_set_link_down = tap_link_set_down,
Signature · 1 line
2.8.0.rc0
Quoted 17 lines · Pascal Mazon
v2 change:
- use snprintf intap_mtusetv3 change:
- calltap_mac_set()only once intap_setup_queue()v4 changes:
- use newtap_ioctlfunction for shared behavior between ops
- update supported packet types
- removeIFF_NOARPflag from link status change
- sync desired MTU to both remote and tap netdevices
- remove support formac_addandmac_removeopsv5 changes:
- rebase after adrien's patches on Tx poll and Rx signaling
- add dependency tolibrte_netfor packet type
Quoted 9 lines
Pascal Mazon (8):
net/tap: remove wrongIFF_NOARPflags
net/tap: refactor ioctl calls
net/tap: add MAC address management
net/tap: add MTU management
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add packet type management
net/tap: add flow control management
Series applied to dpdk-next-net/master, thanks.
Please let me know if I have missed and Ack for the TAP PMD. I believe I have reviewed and agree with all of the changes to TAP at this time.
Quoted 30 lines · Ferruh
Quoted 17 lines · Pascal Mazon
v2 change:
- use snprintf intap_mtusetv3 change:
- calltap_mac_set()only once intap_setup_queue()v4 changes:
- use newtap_ioctlfunction for shared behavior between ops
- update supported packet types
- removeIFF_NOARPflag from link status change
- sync desired MTU to both remote and tap netdevices
- remove support formac_addandmac_removeopsv5 changes:
- rebase after adrien's patches on Tx poll and Rx signaling
- add dependency tolibrte_netfor packet typeQuoted 9 lines
Pascal Mazon (8):
net/tap: remove wrongIFF_NOARPflags
net/tap: refactor ioctl calls
net/tap: add MAC address management
net/tap: add MTU management
net/tap: add speed capabilities
net/tap: add multicast addresses management
net/tap: add packet type management
net/tap: add flow control management
Quoted 1 line
Series applied to dpdk-next-net/master, thanks.
Regards,
Keith
PATCH v3 1/6 net/tap: add MAC address management ops
In reply to Pascal MazonSet a random MAC address when probing the device, as to not leave an empty MAC in pmd->eth_addr.
This MAC will be set on the tap netdevice as soon as it's been created using tun_alloc(). As the tap_mac_add() function depend on the fd in the first rxq, move code from tun_alloc() to tap_setup_queue(), after it's been set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 97 ++++++++++++++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 13 deletions(-)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +84 -13
151 lines not on this page · raw message
Signature · 1 line
2.8.0.rc0
Re: [PATCH v3 1/6] net/tap: add MAC address management ops
Quoted 31 lines · Pascal Mazon
Set a random MAC address when probing the device, as to not leave an empty MAC in
pmd->eth_addr.This MAC will be set on the tap netdevice as soon as it's been created using
tun_alloc(). As thetap_mac_add()function depend on the fd in the first rxq, move code fromtun_alloc()totap_setup_queue(), after it's been set.Signed-off-by Pascal Mazon <[email protected]>--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 97 ++++++++++++++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 13 deletions(-)doc/guides/nics/features/tap.ini +1
-0@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Ydrivers/net/tap/rte_eth_tap.c +0
-0
drivers/net/tap/rte_eth_tap.c line 66
Quoted 4 lines
drivers/net/tap/rte_eth_tap.c +1
-0@@ -63,6 +63,8 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +#define RTE_PMD_TAP_MAX_MAC_ADDRS 1
mac_addr_add and mac_addr_remove not really supported, because only one MAC is supported. For mac_addr_add() all indexes other than 0 will give an error. So only mac_addr_set is supported.
For this case what is the benefit of implementing these functions and claim support, instead of just leaving mac_addr_add and mac_addr_remove NULL?
<...>
drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 597
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+if (qid ==0 ) { +/* +* tap_setup_queue() is called for both tx and rx. +* Let's use dev->data->r/tx_queues[qid] to determine if init +* has already been done. +*/ +if (dev->data->rx_queues[qid] && dev->data->tx_queues[qid]) +return fd; + +tap_mac_set (dev, &pmd->eth_addr);
What is the reason of changing behavior here?
Tap devices assigned random MAC by kernel, and previous implementation was reading that value and using it for DPDK.
Now kernel assigns a random MAC, and DPDK overwrites it another random MAC, previous implementation was simpler I think.
It is OK to move this code tap_setup_queue(), I just missed the benefit of overwriting with DPDK random MAC?
<...>
Re: [PATCH v3 1/6] net/tap: add MAC address management ops
Quoted 42 lines · On Thu, 9 Mar 2017 14:05:51 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 32 lines · Pascal Mazon
Set a random MAC address when probing the device, as to not leave an empty MAC in
pmd->eth_addr.This MAC will be set on the tap netdevice as soon as it's been created using
tun_alloc(). As thetap_mac_add()function depend on the fd in the first rxq, move code fromtun_alloc()totap_setup_queue(), after it's been set.Signed-off-by Pascal Mazon <[email protected]>--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 97++++++++++++++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 13 deletions(-)
(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
f4aca6921ddc..d9b47a003654100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.inidoc/guides/nics/features/tap.ini +1
-0@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindexece3a5fcc897..1e46ee36efa2100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c line 66
Quoted 4 lines
drivers/net/tap/rte_eth_tap.c +1
-0@@ -63,6 +63,8 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +#define RTE_PMD_TAP_MAX_MAC_ADDRS 1
mac_addr_addandmac_addr_removenot really supported, because only one MAC is supported. Formac_addr_add()all indexes other than 0 will give an error. So onlymac_addr_setis supported.
Quoted 4 lines
For this case what is the benefit of implementing these functions and claim support, instead of just leaving
mac_addr_addandmac_addr_removeNULL?
Well, I wanted to implement those along with the mac_addr_set, as they all dealt with mac addresses. But you're right, I might as well leave the ops NULL.
I'll send a new version reflecting this.
Quoted 21 lines
<...>
drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 597
Quoted 12 lines
drivers/net/tap/rte_eth_tap.c +4
-0+if (qid ==0 ) { +/* +* tap_setup_queue() is called for both tx and rx. +* Let's use dev->data->r/tx_queues[qid] to determine if init
drivers/net/tap/rte_eth_tap.c +3
-0+* has already been done. +*/ + if (dev->data->rx_queues[qid] &&dev->data->tx_queues[qid])
drivers/net/tap/rte_eth_tap.c +3
-0+return fd; + +tap_mac_set (dev, &pmd->eth_addr);What is the reason of changing behavior here?
Tap devices assigned random MAC by kernel, and previous implementation was reading that value and using it for DPDK.
Quoted 7 lines
Now kernel assigns a random MAC, and DPDK overwrites it another random MAC, previous implementation was simpler I think.
It is OK to move this code
tap_setup_queue(), I just missed the benefit of overwriting with DPDK random MAC?<...>
As far as I remember, I did it because somewhere the mac_addr_set was checked as part of reconfiguration, which happenened before queue setup was done. The default mac address (dev->data->mac_addrs[0]) got set to 0 and later call for the default mac address tried using this mac address. Or something along those lines.
I'll definitely re-take a closer look at all this for my next version.
Regards,
Pascal
PATCH v3 2/6 net/tap: add speed capabilities
In reply to Pascal MazonTap PMD is flexible, it supports any speed.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Y
drivers/net/tap/rte_eth_tap.c +35 -0
@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed; +uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ; +if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ; + +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Signature · 1 line
2.8.0.rc0
Re: [PATCH v3 2/6] net/tap: add speed capabilities
Quoted 25 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)doc/guides/nics/features/tap.ini +1
-0@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Ydrivers/net/tap/rte_eth_tap.c +0
-0
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 357
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +4
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed;
link_speed is already hardcoded into PMD, so there is nothing to detect here. Would it be different if PMD directly return pmd_link.link_speed?
Quoted 16 lines
drivers/net/tap/rte_eth_tap.c +16
-0+uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ;
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 383
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ;
I would prefer switch here [1], but functionally both are same, it is your call.
[1]
switch (speed) {
case ETH_SPEED_NUM_100G:
capa |= ETH_LINK_SPEED_100G /* fallthrough */ case ETH_SPEED_NUM_56G: capa |= ETH_LINK_SPEED_56G /* fallthrough */
...
};
Quoted 16 lines
drivers/net/tap/rte_eth_tap.c +5
-0+ +return capa; +} +static void tap_dev_info (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); } static void
Re: [PATCH v3 2/6] net/tap: add speed capabilities
Quoted 32 lines · Ferruh
Quoted 28 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35 +++++++++++++++++++++++++++++++++++2 files changed, 36 insertions(+)doc/guides/nics/features/tap.ini +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Ydrivers/net/tap/rte_eth_tap.c +0
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; }
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 357
Quoted 4 lines
drivers/net/tap/rte_eth_tap.c +4
-0+static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed;
link_speedis already hardcoded into PMD, so there is nothing to detect here. Would it be different if PMD directly return pmd_link.link_speed?
The link speed is passed into the PMD via the command line, which means it can change per run.
Quoted 57 lines
Quoted 17 lines
drivers/net/tap/rte_eth_tap.c +16
-0+uint32_t capa =0 ; + +if (speed >=ETH_SPEED_NUM_10M ) + capa |=ETH_LINK_SPEED_10M ; +if (speed >=ETH_SPEED_NUM_100M ) + capa |=ETH_LINK_SPEED_100M ; +if (speed >=ETH_SPEED_NUM_1G ) + capa |=ETH_LINK_SPEED_1G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_2_5G ; +if (speed >=ETH_SPEED_NUM_5G ) + capa |=ETH_LINK_SPEED_5G ; +if (speed >=ETH_SPEED_NUM_10G ) + capa |=ETH_LINK_SPEED_10G ; +if (speed >=ETH_SPEED_NUM_20G ) + capa |=ETH_LINK_SPEED_20G ;drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 383
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+if (speed >=ETH_SPEED_NUM_25G ) + capa |=ETH_LINK_SPEED_25G ; +if (speed >=ETH_SPEED_NUM_40G ) + capa |=ETH_LINK_SPEED_40G ; +if (speed >=ETH_SPEED_NUM_50G ) + capa |=ETH_LINK_SPEED_50G ; +if (speed >=ETH_SPEED_NUM_56G ) + capa |=ETH_LINK_SPEED_56G ; +if (speed >=ETH_SPEED_NUM_100G ) + capa |=ETH_LINK_SPEED_100G ;I would prefer switch here [1], but functionally both are same, it is your call.
[1]
switch (speed) {
caseETH_SPEED_NUM_100G:capa |= ETH_LINK_SPEED_100G /* fallthrough */ case ETH_SPEED_NUM_56G: capa |= ETH_LINK_SPEED_56G /* fallthrough */...
};Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +4
-0+ +return capa; +} +static void
tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info){drivers/net/tap/rte_eth_tap.c +1
-0@@ -363,6 +397,7 @@ tap_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = internals->nb_queues; dev_info->min_rx_bufsize =0 ; dev_info->pci_dev =NULL ; + dev_info->speed_capa =tap_dev_speed_capa (); }
Quoted 1 line
Quoted 1 line
static void
Regards,
Keith
Re: [PATCH v3 2/6] net/tap: add speed capabilities
Quoted 40 lines · Keith
Quoted 32 lines · Ferruh
Quoted 28 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35 +++++++++++++++++++++++++++++++++++2 files changed, 36 insertions(+)doc/guides/nics/features/tap.ini +0
-0@@ -9,6 +9,7 @@ Jumbo frame = YPromiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y ARMv7 = Ydrivers/net/tap/rte_eth_tap.c +0
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused)return 0 ; }Quoted 7 lines
drivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 357
Quoted 4 lines
drivers/net/tap/rte_eth_tap.c +4
-0+static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed;
link_speedis already hardcoded into PMD, so there is nothing to detect here. Would it be different if PMD directly return pmd_link.link_speed?
Quoted 1 line
The link speed is passed into the PMD via the command line, which means it can change per run.
Right, I missed that.
Re: [PATCH v3 2/6] net/tap: add speed capabilities
Quoted 44 lines · On Thu, 9 Mar 2017 16:05:47 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 43 lines · Keith
Quoted 42 lines
On Mar 9, 2017, at 8:18 AM, Yigit, Ferruh <[email protected]> wrote:
Quoted 26 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35
+++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
d9b47a003654..dad5a0561087100644 --- a/doc/guides/nics/features/tap.ini +++ b/doc/guides/nics/features/tap.ini @@ -9,6 +9,7 @@ Jumbo
frame = Y Promiscuous mode = Y
Allmulticast mode = Y
Basic stats = Y
+Speed capabilities = YUnicast MAC filter = Y Other kdrv = Y ARMv7 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex1e46ee36efa2..ef525a3f0826100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev · line 357
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +4
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused) return 0; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed;
link_speedis already hardcoded into PMD, so there is nothing to detect here. Would it be different if PMD directly return pmd_link.link_speed?
Quoted 4 lines
Quoted 2 lines
The link speed is passed into the PMD via the command line, which means it can change per run.
Right, I missed that.
I'll use switch/case in the next version in any case. But yes, as Keith said speed is a runtime option.
Regards,
Pascal
Re: [PATCH v3 2/6] net/tap: add speed capabilities
Quoted 47 lines · On Fri, 10 Mar 2017 10:03:12 +0100 Pascal Mazon <[email protected]> wrote:
Quoted 44 lines · On Thu, 9 Mar 2017 16:05:47 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 43 lines · Keith
Quoted 42 lines
On Mar 9, 2017, at 8:18 AM, Yigit, Ferruh
<[email protected]> wrote:Quoted 26 lines · Pascal Mazon
Tap PMD is flexible, it supports any speed.
Signed-off-by Pascal Mazon <[email protected]>---
doc/guides/nics/features/tap.ini | 1 +drivers/net/tap/rte_eth_tap.c| 35
+++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
d9b47a003654..dad5a0561087100644 --- a/doc/guides/nics/features/tap.ini +++ b/doc/guides/nics/features/tap.ini @@ -9,6 +9,7 @@ Jumbo
frame = Y Promiscuous mode = Y
Allmulticast mode = Y
Basic stats = Y
+Speed capabilities = YUnicast MAC filter = Y Other kdrv = Y ARMv7 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex1e46ee36efa2..ef525a3f0826100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c tap_dev_configure(struct rte_eth_dev *dev · line 357
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +4
-0@@ -351,6 +351,40 @@ tap_dev_configure(struct rte_eth_dev *dev __rte_unused) return 0; } +static uint32_t +tap_dev_speed_capa (void ) +{ +uint32_t speed = pmd_link.link_speed;
link_speedis already hardcoded into PMD, so there is nothing to detect here. Would it be different if PMD directly return pmd_link.link_speed?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The link speed is passed into the PMD via the command line, which means it can change per run.
Right, I missed that.
I'll use switch/case in the next version in any case. But yes, as Keith said speed is a runtime option.
Sorry, I've sent that mail a little too quick. Of course I can't use switch/case as we're not checking exact values matching.
Quoted 3 lines
Regards,
Pascal
PATCH v3 3/6 net/tap: add multicast addresses management
In reply to Pascal MazonA tap netdevice actually receives every packet, without any filtering whatsoever. There is no need for any multicast address registration to receive multicast packets.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Other kdrv = Y
drivers/net/tap/rte_eth_tap.c +13 -0
@@ -721,6 +721,18 @@ tap_tx_queue_setup(struct rte_eth_dev *dev,return 0 ; } +static int +tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, + struct ether_addr *mc_addr_set __rte_unused, + uint32_t nb_mc_addr __rte_unused) +{ +/* +* Nothing to do actually: the tap has no filtering whatsoever, every +* packet is received. +*/ +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -741,6 +753,7 @@ static const struct eth_dev_ops ops = { .mac_addr_remove = tap_mac_remove, .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, + .set_mc_addr_list = tap_set_mc_addr_list, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v3 4/6 net/tap: add MTU management
In reply to Pascal MazonThe MTU is assigned to the tap netdevice according to the argument, but packet transmission and reception just write/read on an fd with the default limit being the socket buffer size.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -9,6 +9,7 @@ Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y Basic stats = Y +MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y
drivers/net/tap/rte_eth_tap.c +37 -0
@@ -733,6 +733,42 @@ tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused,return 0 ; } +static int +tap_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) +{ +struct pmd_internals *pmd = dev->data->dev_private; +struct ifreq ifr; +int err, s; + + s =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (s <0 ) { +RTE_LOG (ERR ,PMD , +"Unable to get a socket for %s to set flags: %s\n" , + pmd->name,strerror (errno)); +return -1 ; + } +memset (&ifr,0 ,sizeof (ifr)); +snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); + err =ioctl (s,SIOCGIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to get %s device MTU: %s\n" , + pmd->name,strerror (errno)); +close (s); +return -1 ; + } + ifr.ifr_mtu = mtu; + err =ioctl (s,SIOCSIFMTU , &ifr); +if (err <0 ) { +RTE_LOG (WARNING ,PMD ,"Unable to set %s mtu %d: %s\n" , + pmd->name, mtu,strerror (errno)); +close (s); +return -1 ; + } +close (s); + dev->data->mtu = mtu; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -754,6 +790,7 @@ static const struct eth_dev_ops ops = { .mac_addr_add = tap_mac_add, .mac_addr_set = tap_mac_set, .set_mc_addr_list = tap_set_mc_addr_list, + .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, };
Signature · 1 line
2.8.0.rc0
PATCH v3 5/6 net/tap: add packet type management
In reply to Pascal MazonAdvertize RTE_PTYPE_UNKNOWN since tap does not report any packet type.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +15 -0
@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
@@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );/* account for the receive frame */ bufs[num_rx++] = mbuf;
@@ -769,6 +772,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -793,6 +807,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Signature · 1 line
2.8.0.rc0
Re: [PATCH v3 5/6] net/tap: add packet type management
Quoted 33 lines · Pascal Mazon
Advertize
RTE_PTYPE_UNKNOWNsince tap does not report any packet type.Signed-off-by Pascal Mazon <[email protected]>--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)doc/guides/nics/features/tap.ini +1
-0@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Ydrivers/net/tap/rte_eth_tap.c +1
-0@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h> #include <sys/types.h> #include <sys/stat.h>
drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 221
Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );
Isn't PMD become inconsistent with this update. It reports RTE_PTYPE_UNKNOWN, but sets mbuf->packet_type with various ptype.
Do we want software packet type parsing in PMD level? Any change some users may not interested with this data at all.
Quoted 30 lines
drivers/net/tap/rte_eth_tap.c +12
-0/* account for the receive frame */ bufs[num_rx++] = mbuf;@@ -769,6 +772,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -793,6 +807,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
Re: [PATCH v3 5/6] net/tap: add packet type management
Quoted 32 lines · On Thu, 9 Mar 2017 14:26:08 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 31 lines · Pascal Mazon
Advertize
RTE_PTYPE_UNKNOWNsince tap does not report any packet type.Signed-off-by Pascal Mazon <[email protected]>--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)(quoted diff) +0
-0b/doc/guides/nics/features/tap.ini index
6aa11874e2bc..7f3f4d661dd7100644 --- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.inidoc/guides/nics/features/tap.ini +1
-0@@ -13,6 +13,7 @@ MTU update = Y Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y +Packet type parsing = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindexd76f1dc83b03..edb5d2a82f12100644 ---a/drivers/net/tap/rte_eth_tap.c
+++b/drivers/net/tap/rte_eth_tap.cdrivers/net/tap/rte_eth_tap.c +1
-0@@ -36,6 +36,7 @@#include <rte_malloc.h> #include <rte_vdev.h> #include <rte_kvargs.h> +#include <rte_net.h>
Quoted 12 lines
drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf · line 222
Quoted 9 lines
drivers/net/tap/rte_eth_tap.c +2
-0#include <sys/types.h> #include <sys/stat.h> @@ -216,6 +217,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf->data_len = len; mbuf->pkt_len = len; mbuf->port = rxq->in_port; + mbuf->packet_type =rte_net_get_ptype (mbuf,NULL , +RTE_PTYPE_ALL_MASK );Isn't PMD become inconsistent with this update. It reports
RTE_PTYPE_UNKNOWN, but setsmbuf->packet_typewith various ptype.
I discussed this briefly with Keith, but my argument was that the librte_net did not provide a list of supported packet types, so I didn't want to have to keep tap supported packet type list in sync with the lib.
But it's actually just a few lines to add, I'll do that and also set a comment to mention that it must be in sync with librte_net.
Quoted 3 lines
Do we want software packet type parsing in PMD level? Any change some users may not interested with this data at all.
Well, most PMDs support packet type parsing, and among the vdev, I inspired that part from virtio, which does software ptype parsing. An application coded with physical hardware PMD in mind doesn't have to be recoded when switching to a tap PMD.
Furthermore, the tap PMD is already using syscalls in its datapath, the cost of software packet parsing won't really change overall performance.
Regards,
Pascal
Quoted 32 lines
Quoted 31 lines
drivers/net/tap/rte_eth_tap.c +12
-0/* account for the receive frame */ bufs[num_rx++] = mbuf;@@ -769,6 +772,17 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return 0; } +static const uint32_t * +tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_UNKNOWN , + + }; + +return ptypes; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,@@ -793,6 +807,7 @@ static const struct eth_dev_ops ops = { .mtu_set = tap_mtu_set, .stats_get = tap_stats_get, .stats_reset = tap_stats_reset, + .dev_supported_ptypes_get = tap_dev_supported_ptypes_get, }; static int
PATCH v3 6/6 net/tap: add flow control management
In reply to Pascal MazonA tap netdevice does not support flow control; ensure nothing but RTE_FC_NONE mode can be set.
--- doc/guides/nics/features/tap.ini | 1 + drivers/net/tap/rte_eth_tap.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
doc/guides/nics/features/tap.ini +1 -0
@@ -14,6 +14,7 @@ Multicast MAC filter = Y Speed capabilities = Y Unicast MAC filter = Y Packet type parsing = Y +Flow control = Y Other kdrv = Y ARMv7 = Y ARMv8 = Y
drivers/net/tap/rte_eth_tap.c +19 -0
@@ -783,6 +783,23 @@ tap_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)return ptypes; } +static int +tap_flow_ctrl_get(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ + fc_conf->mode =RTE_FC_NONE ; +return 0 ; +} + +static int +tap_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused, +struct rte_eth_fc_conf *fc_conf) +{ +if (fc_conf->mode !=RTE_FC_NONE ) +return -ENOTSUP ; +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = tap_dev_start, .dev_stop = tap_dev_stop,
@@ -793,6 +810,8 @@ static const struct eth_dev_ops ops = { .tx_queue_setup = tap_tx_queue_setup, .rx_queue_release = tap_rx_queue_release, .tx_queue_release = tap_tx_queue_release, + .flow_ctrl_get = tap_flow_ctrl_get, + .flow_ctrl_set = tap_flow_ctrl_set, .link_update = tap_link_update, .dev_set_link_up = tap_link_set_up, .dev_set_link_down = tap_link_set_down,
Signature · 1 line
2.8.0.rc0