net/tap: perform proto field update for tun only
PATCH 1/1 net/tap: perform proto field update for tun only
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
--- drivers/net/tap/rte_eth_tap.c | 50 +++++++++++++++++++++++++++---------------- drivers/net/tap/rte_eth_tap.h | 10 +++++++++ 2 files changed, 41 insertions(+), 19 deletions(-)
drivers/net/tap/rte_eth_tap.c +31 -19
@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);
@@ -502,20 +503,24 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf. +* compares whether its v4 or v6. If none match default +* value 0x00 is taken for protocol field. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; +printf ("j %x pi proto %x\n" , j, pi.proto); +rte_pktmbuf_dump (stdout, seg,64 ); + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
@@ -1052,6 +1057,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type; +return *fd; }
@@ -1386,6 +1394,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {
@@ -1421,7 +1430,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ; + +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else
@@ -1440,7 +1451,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
@@ -1812,7 +1823,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , + internals = eth_dev->data->dev_private; +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" ,rte_socket_id ());/* find the ethdev entry */
@@ -1820,7 +1833,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );
drivers/net/tap/rte_eth_tap.h +10 -0
@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode;/* RX features */
@@ -48,6 +56,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */
@@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */
Signature · 1 line
2.7.4
Quoted 45 lines · Vipin Varghese
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>---
drivers/net/tap/rte_eth_tap.c| 50 +++++++++++++++++++++++++++----------------drivers/net/tap/rte_eth_tap.h| 10 +++++++++2 files changed, 41 insertions(+), 19 deletions(-)drivers/net/tap/rte_eth_tap.c +2
-15@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);@@ -502,20 +503,24 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ;
drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 515
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +10
-0+if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf. +* compares whether its v4 or v6. If none match default +* value 0x00 is taken for protocol field.
Little reword and remove the ‘.’ at end of first line.
The logic fetches the first byte of data from mbuf then compares whether it is v4 or v6. If not equal to zero then it must be a protocol field.
drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 521
Quoted 6 lines
drivers/net/tap/rte_eth_tap.c +6
-0+*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; +printf ("j %x pi proto %x\n" , j, pi.proto);
Should this not be a LOG message or is this debug that was not removed? If log message then add move text to explain the output better.
Quoted 107 lines
drivers/net/tap/rte_eth_tap.c +13
-4+rte_pktmbuf_dump (stdout, seg,64 ); + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);@@ -1052,6 +1057,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type; +return *fd; }@@ -1386,6 +1394,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {@@ -1421,7 +1430,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ; + +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else @@ -1440,7 +1451,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,@@ -1812,7 +1823,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , + internals = eth_dev->data->dev_private; +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" ,rte_socket_id ());/* find the ethdev entry */ @@ -1820,7 +1833,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );drivers/net/tap/rte_eth_tap.h +10
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ @@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode;/* RX features */ @@ -48,6 +56,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */ Signature · 1 line
2.7.4
Regards,
Keith
Thanks Keith,
I have made changes and shared v2 patch for both the suggestions.
Thanks
Vipin Varghese
<snipped>
Quoted 27 lines
drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 515
Quoted 9 lines
drivers/net/tap/rte_eth_tap.c +9
-0+/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf. +* compares whether its v4 or v6. If none match default +* value 0x00 is taken for protocol field. Little reword and remove the ‘.’ at end of first line.
The logic fetches the first byte of data from mbuf then compares whether it is v4 or v6. If not equal to zero then it must be a protocol field.
drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 521
Quoted 6 lines
drivers/net/tap/rte_eth_tap.c +6
-0+*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; +printf ("j %x pi proto %x\n" , j, pi.proto);Should this not be a LOG message or is this debug that was not removed? If log message then add move text to explain the output better.
<snipped>
PATCH v2 1/1 net/tap: perform proto field update for tun only
In reply to Vipin VargheseThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
---
Changes in V2:
updated in comment wording - Keith Wiles
remove debug print from tx code - Keith Wiles
--- drivers/net/tap/rte_eth_tap.c | 48 ++++++++++++++++++++++++++----------------- drivers/net/tap/rte_eth_tap.h | 10 +++++++++ 2 files changed, 39 insertions(+), 19 deletions(-)
drivers/net/tap/rte_eth_tap.c +29 -19
@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);
@@ -502,20 +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
@@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type; +return *fd; }
@@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {
@@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ; + +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else
@@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
@@ -1812,7 +1821,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , + internals = eth_dev->data->dev_private; +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" ,rte_socket_id ());/* find the ethdev entry */
@@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );
drivers/net/tap/rte_eth_tap.h +10 -0
@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode;/* RX features */
@@ -48,6 +56,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */
@@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */
Signature · 1 line
2.7.4
Quoted 8 lines · Vipin
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Quoted 7 lines
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V2:
updated in comment wording - Keith Wiles
remove debug print from tx code - Keith Wiles
Acked by: Keith Wiles<[email protected]>
Regards,
Keith
Hi,
I am adding my review although this patch has already been acked. Please find some comments inline. Otherwise it looks OK.
Regards,
Ophir
Quoted 77 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 15, 2018 5:50 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Vipin Varghese <[email protected]>
Subject: [PATCH v2] net/tap: perform proto field update for tun onlyThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V2:
updated in comment wording - Keith Wiles remove debug print from tx code
- Keith Wiles--- drivers/net/tap/rte_eth_tap.c | 48 ++++++++++++++++++++++++++----------- ------ drivers/net/tap/rte_eth_tap.h | 10 +++++++++ 2 files changed, 39 insertions(+), 19 deletions(-)drivers/net/tap/rte_eth_tap.c +3
-1@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -502,20 +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t
nb_pkts)drivers/net/tap/rte_eth_tap.c +16
-14if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 1059
Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type;
It seems there is no usage for rx->type in TAP code. Therefore - can you please remove rx->type assignment?
Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +2
-0+return *fd; }@@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );drivers/net/tap/rte_eth_tap.c +0
-0if (pmd->ioctl_sock ==-1 ) {
drivers/net/tap/rte_eth_tap.c eth_dev_tap_create(struct rte_vdev_device · line 1433
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +1
-1@@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ;
1. It seem you are using 'tap_type' as a global static variable to pass a value to eth_dev_tap_create().
Can you please pass this value by adding a parameter to eth_dev_tap_create() call and remove the global static variable?
2. You are using tap_type with values 0 and 1 which are converted to enums ETH_TUNTAP_TYPE_TUN and ETH_TUNTAP_TYPE_TAP respectively. Can you please always just use the enums (avoiding the conversion)?
Quoted 55 lines
drivers/net/tap/rte_eth_tap.c +2
-0+ +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))drivers/net/tap/rte_eth_tap.c +1
-1eth_random_addr ((uint8_t *)&pmd->eth_addr); else@@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ;rte_memcpy(ifr.ifr_hwaddr.sa_data,
&pmd->eth_addr, @@ -
1812,7 +1821,9 @@rte_pmd_tap_remove(struct rte_vdev_device *dev)drivers/net/tap/rte_eth_tap.c +3
-1struct pmd_internals *internals;int i; - TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u", + internals = eth_dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", + (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" :"TUN",
drivers/net/tap/rte_eth_tap.c +0
-1rte_socket_id());/* find the ethdev entry */ @@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );
tap_flow_implicit_flush(internals, NULL); diff --gita/drivers/net/tap/rte_eth_tap.hb/drivers/net/tap/rte_eth_tap.hindex 67c9d4b..8b0da5a 100644drivers/net/tap/rte_eth_tap.h +7
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
drivers/net/tap/rte_eth_tap.h struct rx_queue { · line 48
Quoted 4 lines
drivers/net/tap/rte_eth_tap.h +1
-0@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */
In seems there is no usage for 'type' field from rx_queue struct in the code. If so - can you please remove it?
drivers/net/tap/rte_eth_tap.h
Quoted 8 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode; /* RX features */ @@ -48,6 +56,7@@ struct
rx_queue{struct
tx_queue{drivers/net/tap/rte_eth_tap.h +1
-0int fd; +int type;/* Type field - TUN|TAP */
Please use spaces (like all other fields in this struct) instead of tabs, so all fields look aligned.
drivers/net/tap/rte_eth_tap.h
Quoted 10 lines
drivers/net/tap/rte_eth_tap.h +0
-0uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */
char name[RTE_ETH_NAME_MAX_LEN]; /* Internal Tap device
name */drivers/net/tap/rte_eth_tap.h +1
-0+int type;/* Type field - TUN|TAP */
Same comment here about replacing tabs with spaces
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */
intremote_if_index; /* remote netdeviceIF_INDEX*/
--
2.7.4
Hi Ophir,
Thanks for the suggestion, once these are merged to dpdk or dpdk-net mainline, I can start the modifications.
Thanks
Vipin Varghese
Quoted 227 lines
-----Original Message-----
From: Ophir Munk [mailto:[email protected]]
Sent: Wednesday, May 16, 2018 3:59 AM
To: Varghese, Vipin <[email protected]>; [email protected]; Wiles, Keith <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v2] net/tap: perform proto field update for tun onlyHi,
I am adding my review although this patch has already been acked. Please find some comments inline. Otherwise it looks OK.Regards,
OphirQuoted 79 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 15, 2018 5:50 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Vipin Varghese <[email protected]>
Subject: [PATCH v2] net/tap: perform proto field update for tun onlyThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V2:
updated in comment wording - Keith Wiles remove debug print from tx code
- Keith Wiles--- drivers/net/tap/rte_eth_tap.c | 48 ++++++++++++++++++++++++++----------- ------ drivers/net/tap/rte_eth_tap.h | 10 +++++++++ 2 files changed, 39 insertions(+), 19 deletions(-)(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex ea6d899..fafd557 100644drivers/net/tap/rte_eth_tap.c +3
-1@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -502,20 +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t
nb_pkts)drivers/net/tap/rte_eth_tap.c +16
-14if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 1059
Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type;It seems there is no usage for
rx->typein TAP code. Therefore - can you please removerx->typeassignment?Quoted 14 lines
drivers/net/tap/rte_eth_tap.c +2
-0+return *fd; }@@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev,char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );drivers/net/tap/rte_eth_tap.c +0
-0if (pmd->ioctl_sock ==-1 ) {drivers/net/tap/rte_eth_tap.c eth_dev_tap_create(struct rte_vdev_device *vdev, · line 1433
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +1
-1@@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev,char *tap_name, pmd->txq[i].fd = -1; } -if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ;1. It seem you are using '
tap_type' as a global static variable to pass a value toeth_dev_tap_create().
Can you please pass this value by adding a parameter toeth_dev_tap_create()call and remove the global static variable?
2. You are usingtap_typewith values 0 and 1 which are converted to enumsETH_TUNTAP_TYPE_TUNandETH_TUNTAP_TYPE_TAPrespectively. Can you please always just use the enums (avoiding the conversion)?Quoted 55 lines
drivers/net/tap/rte_eth_tap.c +2
-0+ +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))drivers/net/tap/rte_eth_tap.c +1
-1eth_random_addr ((uint8_t *)&pmd->eth_addr); else@@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ;rte_memcpy(ifr.ifr_hwaddr.sa_data,
&pmd->eth_addr, @@ -
1812,7 +1821,9 @@rte_pmd_tap_remove(struct rte_vdev_device *dev)drivers/net/tap/rte_eth_tap.c +3
-1struct pmd_internals *internals;int i; - TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u", + internals = eth_dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", + (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" :"TUN",
drivers/net/tap/rte_eth_tap.c +0
-1rte_socket_id());/* find the ethdev entry */ @@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );
tap_flow_implicit_flush(internals, NULL); diff --gita/drivers/net/tap/rte_eth_tap.hb/drivers/net/tap/rte_eth_tap.hindex 67c9d4b..8b0da5a 100644drivers/net/tap/rte_eth_tap.h +7
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ drivers/net/tap/rte_eth_tap.h struct rx_queue { · line 48
Quoted 4 lines
drivers/net/tap/rte_eth_tap.h +1
-0@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ In seems there is no usage for 'type' field from
rx_queuestruct in the code. If so
- can you please remove it?drivers/net/tap/rte_eth_tap.h struct rx_queue {
Quoted 3 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode; /* RX features */ @@ -48,6 +56,7@@
drivers/net/tap/rte_eth_tap.h
Quoted 5 lines
struct
rx_queue{struct
tx_queue{drivers/net/tap/rte_eth_tap.h +1
-0int fd; +int type;/* Type field - TUN|TAP */ Please use spaces (like all other fields in this struct) instead of tabs, so all fields look aligned.
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 67
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 69
Quoted 2 lines
drivers/net/tap/rte_eth_tap.h +1
-0char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ Same comment here about replacing tabs with spaces
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int
remote_if_index; /* remote netdeviceIF_INDEX*/
--
2.7.4
Hi Ophir, Keith and Ferruh,
I have shared v3 with all the suggested changes.
Thanks
Vipin Varghese
Quoted 248 lines
-----Original Message-----
From: Varghese, Vipin
Sent: Tuesday, May 22, 2018 12:04 PM
To: Ophir Munk <[email protected]>; [email protected]; Wiles, Keith <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v2] net/tap: perform proto field update for tun onlyHi Ophir,
Thanks for the suggestion, once these are merged to dpdk or dpdk-net mainline, I can start the modifications.
Thanks
Vipin VargheseQuoted 123 lines
-----Original Message-----
From: Ophir Munk [mailto:[email protected]]
Sent: Wednesday, May 16, 2018 3:59 AM
To: Varghese, Vipin <[email protected]>; [email protected]; Wiles, Keith <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v2] net/tap: perform proto field update for tun onlyHi,
I am adding my review although this patch has already been acked. Please find some comments inline. Otherwise it looks OK.Regards,
OphirQuoted 80 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 15, 2018 5:50 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Vipin Varghese <[email protected]>
Subject: [PATCH v2] net/tap: perform proto field update for tun onlyThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V2:
updated in comment wording - Keith Wiles remove debug print from tx code
- Keith Wiles--- drivers/net/tap/rte_eth_tap.c | 48 ++++++++++++++++++++++++++----------- ------ drivers/net/tap/rte_eth_tap.h | 10 +++++++++ 2 files changed, 39 insertions(+), 19 deletions(-)(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex ea6d899..fafd557 100644drivers/net/tap/rte_eth_tap.c +4
-1@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -502,20 +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, +uint16_t
nb_pkts)drivers/net/tap/rte_eth_tap.c +16
-14if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 1059
Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type;It seems there is no usage for
rx->typein TAP code. Therefore - can you please removerx->typeassignment?Quoted 18 lines
drivers/net/tap/rte_eth_tap.c +2
-0+return *fd; }@@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );drivers/net/tap/rte_eth_tap.c +0
-0if (pmd->ioctl_sock ==-1 ) {@@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; }Quoted 10 lines
drivers/net/tap/rte_eth_tap.c eth_dev_tap_create(struct rte_vdev_device · line 1433
Quoted 3 lines
drivers/net/tap/rte_eth_tap.c +1
-1-if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ;1. It seem you are using '
tap_type' as a global static variable to pass a value toeth_dev_tap_create().
Can you please pass this value by adding a parameter toeth_dev_tap_create()call and remove the global static variable?
2. You are usingtap_typewith values 0 and 1 which are converted to enumsETH_TUNTAP_TYPE_TUNandETH_TUNTAP_TYPE_TAPrespectively.Can
Quoted 97 lines
you please always just use the enums (avoiding the conversion)?
Quoted 55 lines
drivers/net/tap/rte_eth_tap.c +2
-0+ +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))drivers/net/tap/rte_eth_tap.c +1
-1eth_random_addr ((uint8_t *)&pmd->eth_addr); else@@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ;rte_memcpy(ifr.ifr_hwaddr.sa_data,
&pmd->eth_addr, @@ -
1812,7 +1821,9 @@rte_pmd_tap_remove(struct rte_vdev_device *dev)drivers/net/tap/rte_eth_tap.c +3
-1struct pmd_internals *internals;int i; - TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u", + internals = eth_dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", + (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" :"TUN",
drivers/net/tap/rte_eth_tap.c +0
-1rte_socket_id());/* find the ethdev entry */ @@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );
tap_flow_implicit_flush(internals, NULL); diff --gita/drivers/net/tap/rte_eth_tap.hb/drivers/net/tap/rte_eth_tap.hindex 67c9d4b..8b0da5a 100644drivers/net/tap/rte_eth_tap.h +7
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ drivers/net/tap/rte_eth_tap.h struct rx_queue { · line 48
Quoted 4 lines
drivers/net/tap/rte_eth_tap.h +1
-0@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ In seems there is no usage for 'type' field from
rx_queuestruct in the code. If so
- can you please remove it?drivers/net/tap/rte_eth_tap.h struct rx_queue {
Quoted 3 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode; /* RX features */ @@ -48,6 +56,7@@
drivers/net/tap/rte_eth_tap.h
Quoted 5 lines
struct
rx_queue{struct
tx_queue{drivers/net/tap/rte_eth_tap.h +1
-0int fd; +int type;/* Type field - TUN|TAP */ Please use spaces (like all other fields in this struct) instead of tabs, so all fields look aligned.
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 67
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 69
Quoted 2 lines
drivers/net/tap/rte_eth_tap.h +1
-0char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ Same comment here about replacing tabs with spaces
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int
remote_if_index; /* remote netdeviceIF_INDEX*/
--
2.7.4
Quoted 7 lines · Vipin
Hi Ophir, Keith and Ferruh,
I have shared v3 with all the suggested changes.
I just sent another change, sorry I did not catch if before, which I obviously was not paying attention.
Quoted 253 lines
Thanks
Vipin VargheseQuoted 248 lines
-----Original Message-----
From: Varghese, Vipin
Sent: Tuesday, May 22, 2018 12:04 PM
To: Ophir Munk <[email protected]>; [email protected]; Wiles, Keith <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v2] net/tap: perform proto field update for tun onlyHi Ophir,
Thanks for the suggestion, once these are merged to dpdk or dpdk-net mainline, I can start the modifications.
Thanks
Vipin VargheseQuoted 123 lines
-----Original Message-----
From: Ophir Munk [mailto:[email protected]]
Sent: Wednesday, May 16, 2018 3:59 AM
To: Varghese, Vipin <[email protected]>; [email protected]; Wiles, Keith <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v2] net/tap: perform proto field update for tun onlyHi,
I am adding my review although this patch has already been acked. Please find some comments inline. Otherwise it looks OK.Regards,
OphirQuoted 80 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 15, 2018 5:50 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Vipin Varghese <[email protected]>
Subject: [PATCH v2] net/tap: perform proto field update for tun onlyThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V2:
updated in comment wording - Keith Wiles remove debug print from tx code
- Keith Wiles
---drivers/net/tap/rte_eth_tap.c| 48
++++++++++++++++++++++++++-----------
------drivers/net/tap/rte_eth_tap.h| 10 +++++++++2 files changed, 39 insertions(+), 19 deletions(-)(quoted diff) +0
-0
b/drivers/net/tap/rte_eth_tap.cindex ea6d899..fafd557 100644drivers/net/tap/rte_eth_tap.c +4
-1@@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -502,20 +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, +uint16_t
nb_pkts)if (rte_pktmbuf_pkt_len(mbuf) > max_size) break;drivers/net/tap/rte_eth_tap.c +16
-14-/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : + (j ==0x60 ) ?0xdd86 :0x00 ; + }iovecs[0].iov_base = π iovecs[0].iov_len = sizeof(pi);drivers/net/tap/rte_eth_tap.c tap_setup_queue(struct rte_eth_dev *dev, · line 1059
Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; + rx->type = pmd->type;It seems there is no usage for
rx->typein TAP code. Therefore - can you please removerx->typeassignment?Quoted 18 lines
drivers/net/tap/rte_eth_tap.c +2
-0+return *fd; }@@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type =ETH_TUNTAP_TYPE_UNKNOWN ; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock == -1) {drivers/net/tap/rte_eth_tap.c +0
-0@@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; }Quoted 10 lines
drivers/net/tap/rte_eth_tap.c eth_dev_tap_create(struct rte_vdev_device · line 1433
Quoted 3 lines
drivers/net/tap/rte_eth_tap.c +1
-1-if (tap_type) { + pmd->type = (tap_type) ?ETH_TUNTAP_TYPE_TAP :ETH_TUNTAP_TYPE_TUN ;1. It seem you are using '
tap_type' as a global static variable to pass a value toeth_dev_tap_create().
Can you please pass this value by adding a parameter toeth_dev_tap_create()call and remove the global static variable?
2. You are usingtap_typewith values 0 and 1 which are converted to enumsETH_TUNTAP_TYPE_TUNandETH_TUNTAP_TYPE_TAPrespectively.Can
Quoted 97 lines
you please always just use the enums (avoiding the conversion)?
Quoted 55 lines
drivers/net/tap/rte_eth_tap.c +2
-0+ +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr((uint8_t *)&pmd->eth_addr); elsedrivers/net/tap/rte_eth_tap.c +1
-1@@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ;rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr, @@ - 1812,7 +1821,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) struct pmd_internals *internals; int i;drivers/net/tap/rte_eth_tap.c +3
-1- TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u", + internals = eth_dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", + (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" :"TUN",
rte_socket_id()); /* find the ethdev entry */drivers/net/tap/rte_eth_tap.c +0
-1@@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)if (!eth_dev)return 0 ; - internals = eth_dev->data->dev_private;if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush(internals, NULL); diff --git
a/drivers/net/tap/rte_eth_tap.hb/drivers/net/tap/rte_eth_tap.hindex 67c9d4b..8b0da5a 100644drivers/net/tap/rte_eth_tap.h +7
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ drivers/net/tap/rte_eth_tap.h struct rx_queue { · line 48
Quoted 4 lines
drivers/net/tap/rte_eth_tap.h +1
-0@@ -38,6 +45,7 @@ struct rx_queue {uint32_t trigger_seen;/* Last seen Rx trigger value */ uint16_t in_port;/* Port ID */ int fd; +int type;/* Type field - TUN|TAP */ In seems there is no usage for 'type' field from
rx_queuestruct in the code. If so
- can you please remove it?drivers/net/tap/rte_eth_tap.h struct rx_queue {
Quoted 3 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct pkt_stats stats;/* Stats for this RX queue */ uint16_t nb_rx_desc;/* max number of mbufs available */ struct rte_eth_rxmode *rxmode; /* RX features */ @@ -48,6 +56,7@@
drivers/net/tap/rte_eth_tap.h
Quoted 5 lines
struct
rx_queue{struct tx_queue { int fd;drivers/net/tap/rte_eth_tap.h +1
-0+int type;/* Type field - TUN|TAP */ Please use spaces (like all other fields in this struct) instead of tabs, so all fields look aligned.
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 67
Quoted 6 lines
uint16_t *mtu; /* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */ struct pkt_stats stats; /* Stats for this TX queue */drivers/net/tap/rte_eth_tap.h +0
-0@@ -57,6 +66,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */
drivers/net/tap/rte_eth_tap.h struct pmd_internals { · line 69
Quoted 2 lines
drivers/net/tap/rte_eth_tap.h +1
-0char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ Same comment here about replacing tabs with spaces
Quoted 6 lines
drivers/net/tap/rte_eth_tap.h +0
-0struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int
remote_if_index; /* remote netdeviceIF_INDEX*/
--
2.7.4
Regards,
Keith
PATCH v3 1/1 net/tap: perform proto field update for tun only
In reply to Vipin VargheseThe TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
---
Changes in V3:
- remove type field from rx struct - Ophir Munk
- add space for comment in struct - Ophir Munk
- pass type field into eth_dev_tap_create - Ophir Munk
- replace with enum value for type - Ophir Munk
- return as 'not supported' for mac_set - Vipin Varghese
Changes in V2:
- updated in comment wording - Keith Wiles
- remove debug print from tx code - Keith Wiles
--- drivers/net/tap/rte_eth_tap.c | 61 +++++++++++++++++++++++++------------------ drivers/net/tap/rte_eth_tap.h | 9 +++++++ 2 files changed, 45 insertions(+), 25 deletions(-)
drivers/net/tap/rte_eth_tap.c +36 -25
@@ -68,7 +68,6 @@ static const char *valid_arguments[] = {static int tap_unit;static unsigned int tun_unit; -static int tap_type;static char tuntap_name[8 ];static volatile uint32_t tap_trigger;/* Rx trigger */
@@ -116,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);
@@ -472,20 +472,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
@@ -928,6 +930,9 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)struct ifreq ifr;int ret; +if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) +return -ENOTSUP ; +if (is_zero_ether_addr (mac_addr)) {TAP_LOG (ERR ,"%s: can't set an empty MAC address" , dev->device->name);
@@ -1025,6 +1030,8 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; +return *fd; }
@@ -1342,7 +1349,8 @@ static const struct eth_dev_ops ops = {static int eth_dev_tap_create (struct rte_vdev_device *vdev,char *tap_name, -char *remote_iface,struct ether_addr *mac_addr) +char *remote_iface,struct ether_addr *mac_addr, +enum rte_tuntap_type type) {int numa_node =rte_socket_id ();struct rte_eth_dev *dev;
@@ -1364,6 +1372,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type = type; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {
@@ -1400,7 +1409,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else
@@ -1423,7 +1432,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
@@ -1642,7 +1651,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)char tun_name[RTE_ETH_NAME_MAX_LEN ];char remote_iface[RTE_ETH_NAME_MAX_LEN ]; - tap_type =0 ;strcpy (tuntap_name,"TUN" ); name =rte_vdev_device_name (dev);
@@ -1673,7 +1681,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tun for %s as %s" , name, tun_name); - ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 ); + ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 , +ETH_TUNTAP_TYPE_TUN ); leave:if (ret ==-1 ) {
@@ -1700,7 +1709,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)struct ether_addr user_mac = { .addr_bytes = {0 } };struct rte_eth_dev *eth_dev; - tap_type =1 ;strcpy (tuntap_name,"TAP" ); name =rte_vdev_device_name (dev);
@@ -1762,7 +1770,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tap for %s as %s" , name, tap_name); - ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac); + ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac, +ETH_TUNTAP_TYPE_TAP ); leave:if (ret ==-1 ) {
@@ -1784,15 +1793,17 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , -rte_socket_id ()); -/* find the ethdev entry */ eth_dev =rte_eth_dev_allocated (rte_vdev_device_name (dev));if (!eth_dev)return 0 ; internals = eth_dev->data->dev_private; + +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" , +rte_socket_id ()); +if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );
drivers/net/tap/rte_eth_tap.h +9 -0
@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
@@ -48,6 +55,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */
@@ -57,6 +65,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */
Signature · 1 line
2.7.4
Quoted 18 lines · Vipin
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Changes in V3:
- remove type field from rx struct - Ophir Munk
- add space for comment in struct - Ophir Munk
- pass type field intoeth_dev_tap_create- Ophir Munk
- replace with enum value for type - Ophir Munk
- return as 'not supported' formac_set- Vipin Varghese
Quoted 4 lines
Changes in V2:
- updated in comment wording - Keith Wiles
- remove debug print from tx code - Keith Wiles
—
Sorry, I did not catch the problem below before :-(
Quoted 48 lines
drivers/net/tap/rte_eth_tap.c| 61 +++++++++++++++++++++++++------------------drivers/net/tap/rte_eth_tap.h| 9 +++++++2 files changed, 45 insertions(+), 25 deletions(-)drivers/net/tap/rte_eth_tap.c +0
-1@@ -68,7 +68,6 @@ static const char *valid_arguments[] = {static int tap_unit;static unsigned int tun_unit; -static int tap_type;static char tuntap_name[8 ];static volatile
uint32_ttap_trigger; /* Rx trigger */drivers/net/tap/rte_eth_tap.c +7
-14@@ -116,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);@@ -472,20 +472,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j == 0x40) ? 0x0008 : +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP
drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 489
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +9
-0+* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : (j ==0x60 ) ?0xdd86 :0x00 ;
Warning Will Robinson: Magic numbers :-)
Can we use the correct values here ETHERTYPE_IPV6 and ETHERTYPE_IP and then use htons() on the values please.
Quoted 153 lines
drivers/net/tap/rte_eth_tap.c +6
-0+ } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);@@ -928,6 +930,9 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)struct ifreq ifr;int ret; +if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) +return -ENOTSUP ; +if (is_zero_ether_addr (mac_addr)) {TAP_LOG (ERR ,"%s: can't set an empty MAC address" , dev->device->name);@@ -1025,6 +1030,8 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; +return *fd; }@@ -1342,7 +1349,8 @@ static const struct eth_dev_ops ops = {static int
eth_dev_tap_create(structrte_vdev_device*vdev, char*tap_name,drivers/net/tap/rte_eth_tap.c +2
-1- char *remote_iface, struct ether_addr *mac_addr) + char *remote_iface, struct ether_addr *mac_addr, + enum rte_tuntap_type type){ int numa_node = rte_socket_id(); struct rte_eth_dev *dev;drivers/net/tap/rte_eth_tap.c +5
-4@@ -1364,6 +1372,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type = type; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {@@ -1400,7 +1409,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else @@ -1423,7 +1432,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,@@ -1642,7 +1651,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)char tun_name[RTE_ETH_NAME_MAX_LEN ];char remote_iface[RTE_ETH_NAME_MAX_LEN ]; - tap_type =0 ;strcpy (tuntap_name,"TUN" ); name =rte_vdev_device_name (dev);@@ -1673,7 +1681,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tun for %s as %s" , name, tun_name); - ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 ); + ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 , +ETH_TUNTAP_TYPE_TUN );leave:
if (ret == -1) {drivers/net/tap/rte_eth_tap.c +2
-2@@ -1700,7 +1709,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)struct ether_addr user_mac = { .addr_bytes = {0 } };struct rte_eth_dev *eth_dev; - tap_type =1 ;strcpy (tuntap_name,"TAP" ); name =rte_vdev_device_name (dev);@@ -1762,7 +1770,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tap for %s as %s" , name, tap_name); - ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac); + ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac, +ETH_TUNTAP_TYPE_TAP );leave:
if (ret == -1) {drivers/net/tap/rte_eth_tap.c +5
-3@@ -1784,15 +1793,17 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , -rte_socket_id ()); -/* find the ethdev entry */ eth_dev =rte_eth_dev_allocated (rte_vdev_device_name (dev));if (!eth_dev)return 0 ; internals = eth_dev->data->dev_private; + +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" , +rte_socket_id ()); +if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );drivers/net/tap/rte_eth_tap.h +9
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ @@ -48,6 +55,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +65,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */ Signature · 1 line
2.7.4
Regards,
Keith
HI Keith,
Thanks for pointing out, please find my answer and update below
<Snipped>
Quoted 17 lines
Quoted 13 lines
drivers/net/tap/rte_eth_tap.c +13
-0+/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j == 0x40) ? 0x0008 :Quoted 1 line
(j == 0x60) ? 0xdd86 : 0x00;Warning Will Robinson: Magic numbers :-)
Quoted 2 lines
Can we use the correct values here
ETHERTYPE_IPV6andETHERTYPE_IPand then usehtons()on the values please.
Earlier I refrained from doing this assuming htnos comparison is done for each packet leading to extra cycles. So updated the comments with explanation for logic explanation and readability.
But I am ok to in co-operate the idea of using MACRO with htnos. I have used ETHER_TYPE_IPv4 and ETHER_TYPE_IPv6 which does not require extra include. The changes are available in v4 version.
Quoted 2 lines
Quoted 2 lines
drivers/net/tap/rte_eth_tap.c +1
-0+ }
<Snipped>
Hi,
Overall it looks good.
Please note a few more comments below.
Quoted 9 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 22, 2018 1:47 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>; Vipin Varghese <[email protected]>
Subject: [PATCH v3] net/tap: perform proto field update for tun only
Quoted 6 lines
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Shouldn't it be a fix commit?
If so - please update the commit title, add Fixes: ... , Cc: [email protected]...
Quoted 75 lines
Changes in V3:
- remove type field from rx struct - Ophir Munk
- add space for comment in struct - Ophir Munk
- pass type field intoeth_dev_tap_create- Ophir Munk
- replace with enum value for type - Ophir Munk
- return as 'not supported' formac_set- Vipin VargheseChanges in V2:
- updated in comment wording - Keith Wiles
- remove debug print from tx code - Keith Wiles--- drivers/net/tap/rte_eth_tap.c | 61 +++++++++++++++++++++++++------------- ----- drivers/net/tap/rte_eth_tap.h | 9 +++++++ 2 files changed, 45 insertions(+), 25 deletions(-)drivers/net/tap/rte_eth_tap.c +3
-2@@ -68,7 +68,6 @@ static const char *valid_arguments[] = { static int tap_unit;static unsigned int tun_unit; -static int tap_type;static char tuntap_name[8 ];static volatile uint32_t tap_trigger;/* Rx trigger */ @@ -116,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name); TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -472,20 +472,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t
nb_pkts)drivers/net/tap/rte_eth_tap.c +15
-13if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?0x0008 : (j ==0x60 ) ?0xdd86 :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
drivers/net/tap/rte_eth_tap.c tap_mac_set(struct rte_eth_dev *dev, struct · line 935
Quoted 6 lines
drivers/net/tap/rte_eth_tap.c +2
-0@@ -928,6 +930,9 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)struct ifreq ifr;int ret; +if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) +return -ENOTSUP ;
Can you please add a TAP_LOG(ERR, ...) to log this error similar to other error cases in this function?
Quoted 151 lines
drivers/net/tap/rte_eth_tap.c +1
-0+if (is_zero_ether_addr (mac_addr)) { TAP_LOG(ERR, "%s: can't set an empty MAC address",drivers/net/tap/rte_eth_tap.c +5
-1dev->device->name);@@ -1025,6 +1030,8 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; +return *fd; }@@ -1342,7 +1349,8 @@ static const struct eth_dev_ops ops = {static int eth_dev_tap_create (struct rte_vdev_device *vdev,char *tap_name, -char *remote_iface,struct ether_addr *mac_addr) +char *remote_iface,struct ether_addr *mac_addr, +enum rte_tuntap_type type) {int numa_node =rte_socket_id ();struct rte_eth_dev *dev;@@ -1364,6 +1372,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type = type; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );drivers/net/tap/rte_eth_tap.c +1
-1if (pmd->ioctl_sock ==-1 ) {@@ -1400,7 +1409,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);drivers/net/tap/rte_eth_tap.c +1
-1else @@ -1423,7 +1432,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ;rte_memcpy(ifr.ifr_hwaddr.sa_data,
&pmd->eth_addr, @@ -
1642,7 +1651,6 @@rte_pmd_tun_probe(struct rte_vdev_device *dev)drivers/net/tap/rte_eth_tap.c +4
-4char tun_name[RTE_ETH_NAME_MAX_LEN ];char remote_iface[RTE_ETH_NAME_MAX_LEN ]; - tap_type =0 ;strcpy (tuntap_name,"TUN" ); name =rte_vdev_device_name (dev);@@ -1673,7 +1681,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tun for %s as %s" , name, tun_name); - ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 ); + ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 , +ETH_TUNTAP_TYPE_TUN ); leave:if (ret ==-1 ) {@@ -1700,7 +1709,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)struct ether_addr user_mac = { .addr_bytes = {0 } };struct rte_eth_dev *eth_dev; - tap_type =1 ;strcpy (tuntap_name,"TAP" ); name =rte_vdev_device_name (dev);@@ -1762,7 +1770,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tap for %s as %s" , name, tap_name); - ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac); + ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac, +ETH_TUNTAP_TYPE_TAP ); leave:drivers/net/tap/rte_eth_tap.c +5
-3if (ret ==-1 ) {@@ -1784,15 +1793,17 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , -rte_socket_id ()); -/* find the ethdev entry */ eth_dev =rte_eth_dev_allocated (rte_vdev_device_name (dev));if (!eth_dev)return 0 ; internals = eth_dev->data->dev_private; + +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" , +rte_socket_id ()); +if (internals->nlsk_fd) {drivers/net/tap/rte_eth_tap.c +0
-0tap_flow_flush (eth_dev,NULL ); tap_flow_implicit_flush(internals, NULL); diff --git
a/drivers/net/tap/rte_eth_tap.hb/drivers/net/tap/rte_eth_tap.hindex c87a0b8..7b21d0d 100644drivers/net/tap/rte_eth_tap.h +8
-0@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */ @@ -48,6 +55,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */ @@ -57,6 +65,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */
char name[RTE_ETH_NAME_MAX_LEN]; /* Internal Tap device
name */drivers/net/tap/rte_eth_tap.h +1
-0+int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */
intremote_if_index; /* remote netdeviceIF_INDEX*/
--
2.7.4
Hi Ophir,
Thanks for inputs, please find my answers inline to the mail
Quoted 22 lines
-----Original Message-----
From: Ophir Munk [mailto:[email protected]]
Sent: Tuesday, May 22, 2018 8:35 PM
To: Varghese, Vipin <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Wiles, Keith <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>
Subject: RE: [PATCH v3] net/tap: perform proto field update for tun onlyHi,
Overall it looks good.
Please note a few more comments below.Quoted 9 lines
-----Original Message-----
From: Vipin Varghese [mailto:[email protected]]
Sent: Tuesday, May 22, 2018 1:47 PM
To: [email protected]; [email protected]; [email protected]; Ophir Munk <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Olga Shern <[email protected]>; Vipin Varghese <[email protected]>
Subject: [PATCH v3] net/tap: perform proto field update for tun only
Quoted 8 lines
Quoted 6 lines
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Suggested-by Ferruh Yigit <[email protected]>---
Shouldn't it be a fix commit?
The following code base is not merged with stable, dev or next-net branch. Hence do we 'fix commit' this?
Quoted 19 lines
If so - please update the commit title, add Fixes: ... , Cc: [email protected]...
Quoted 17 lines
Changes in V3:
- remove type field from rx struct - Ophir Munk
- add space for comment in struct - Ophir Munk
- pass type field intoeth_dev_tap_create- Ophir Munk
- replace with enum value for type - Ophir Munk
- return as 'not supported' formac_set- Vipin VargheseChanges in V2:
- updated in comment wording - Keith Wiles
- remove debug print from tx code - Keith Wiles--- drivers/net/tap/rte_eth_tap.c | 61 +++++++++++++++++++++++++------------- ----- drivers/net/tap/rte_eth_tap.h | 9 +++++++ 2 files changed, 45 insertions(+), 25 deletions(-)
<Snipped>
Quoted 7 lines
drivers/net/tap/rte_eth_tap.c tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) · line 934
Quoted 3 lines
drivers/net/tap/rte_eth_tap.c +2
-0+if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) +return -ENOTSUP ;Can you please add a
TAP_LOG(ERR, ...)to log this error similar to other error cases in this function?
Yes, I will add the change in v4 and share the same.
Quoted 2 lines
Quoted 2 lines
+
<Snipped>
PATCH v4 1/1 net/tap: perform proto field update for tun only
In reply to Vipin VargheseFrom: Vipin Varghese <[email protected]>
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
---
Cc: Ophir Munk <[email protected]>
--- drivers/net/tap/rte_eth_tap.c | 66 ++++++++++++++++++++++++++----------------- drivers/net/tap/rte_eth_tap.h | 9 ++++++ 2 files changed, 49 insertions(+), 26 deletions(-)
drivers/net/tap/rte_eth_tap.c +40 -26
@@ -68,7 +68,6 @@ static const char *valid_arguments[] = {static int tap_unit;static unsigned int tun_unit; -static int tap_type;static char tuntap_name[8 ];static volatile uint32_t tap_trigger;/* Rx trigger */
@@ -116,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);
@@ -472,20 +472,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?rte_cpu_to_be_16 (ETHER_TYPE_IPv4) : + (j ==0x60 ) ?rte_cpu_to_be_16 (ETHER_TYPE_IPv6) :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
@@ -928,6 +930,12 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)struct ifreq ifr;int ret; +if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) { +TAP_LOG (ERR ,"%s: can't MAC address for TUN" , + dev->device->name); +return -ENOTSUP ; + } +if (is_zero_ether_addr (mac_addr)) {TAP_LOG (ERR ,"%s: can't set an empty MAC address" , dev->device->name);
@@ -1025,6 +1033,8 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; +return *fd; }
@@ -1342,7 +1352,8 @@ static const struct eth_dev_ops ops = {static int eth_dev_tap_create (struct rte_vdev_device *vdev,char *tap_name, -char *remote_iface,struct ether_addr *mac_addr) +char *remote_iface,struct ether_addr *mac_addr, +enum rte_tuntap_type type) {int numa_node =rte_socket_id ();struct rte_eth_dev *dev;
@@ -1364,6 +1375,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type = type; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {
@@ -1400,7 +1412,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else
@@ -1423,7 +1435,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
@@ -1642,7 +1654,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)char tun_name[RTE_ETH_NAME_MAX_LEN ];char remote_iface[RTE_ETH_NAME_MAX_LEN ]; - tap_type =0 ;strcpy (tuntap_name,"TUN" ); name =rte_vdev_device_name (dev);
@@ -1673,7 +1684,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tun for %s as %s" , name, tun_name); - ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 ); + ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 , +ETH_TUNTAP_TYPE_TUN ); leave:if (ret ==-1 ) {
@@ -1700,7 +1712,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)struct ether_addr user_mac = { .addr_bytes = {0 } };struct rte_eth_dev *eth_dev; - tap_type =1 ;strcpy (tuntap_name,"TAP" ); name =rte_vdev_device_name (dev);
@@ -1762,7 +1773,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tap for %s as %s" , name, tap_name); - ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac); + ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac, +ETH_TUNTAP_TYPE_TAP ); leave:if (ret ==-1 ) {
@@ -1784,15 +1796,17 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , -rte_socket_id ()); -/* find the ethdev entry */ eth_dev =rte_eth_dev_allocated (rte_vdev_device_name (dev));if (!eth_dev)return 0 ; internals = eth_dev->data->dev_private; + +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" , +rte_socket_id ()); +if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );
drivers/net/tap/rte_eth_tap.h +9 -0
@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
@@ -48,6 +55,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */
@@ -57,6 +65,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */
Signature · 1 line
2.14.3
Quoted 10 lines · Ferruh Yigit
From: Vipin Varghese <[email protected]>
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Signed-off-by Vipin Varghese <[email protected]>Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Ophir Munk <[email protected]>
Self Nack. Forget to rename patch title, will send a new version soon.
PATCH v5 1/1 net/tap: fix proto field for tun
In reply to Ferruh YigitFrom: Vipin Varghese <[email protected]>
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
---
Cc: Ophir Munk <[email protected]>
--- drivers/net/tap/rte_eth_tap.c | 66 ++++++++++++++++++++++++++----------------- drivers/net/tap/rte_eth_tap.h | 9 ++++++ 2 files changed, 49 insertions(+), 26 deletions(-)
drivers/net/tap/rte_eth_tap.c +40 -26
@@ -68,7 +68,6 @@ static const char *valid_arguments[] = {static int tap_unit;static unsigned int tun_unit; -static int tap_type;static char tuntap_name[8 ];static volatile uint32_t tap_trigger;/* Rx trigger */
@@ -116,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd)* Do not set IFF_NO_PI as packet information header will be needed * to check if a received packet has been truncated. */ - ifr.ifr_flags = (tap_type) ?IFF_TAP :IFF_TUN |IFF_POINTOPOINT ; + ifr.ifr_flags = (pmd->type ==ETH_TUNTAP_TYPE_TAP ) ? +IFF_TAP :IFF_TUN |IFF_POINTOPOINT ;snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , pmd->name);TAP_LOG (DEBUG ,"ifr_name '%s'" , ifr.ifr_name);
@@ -472,20 +472,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)if (rte_pktmbuf_pkt_len (mbuf) > max_size)break ; -/* -* TUN and TAP are created with IFF_NO_PI disabled. -* For TUN PMD this mandatory as fields are used by -* Kernel tun.c to determine whether its IP or non IP -* packets. -* -* The logic fetches the first byte of data from mbuf. -* compares whether its v4 or v6. If none matches default -* value 0x00 is taken for protocol field. -*/ - char *buff_data = rte_pktmbuf_mtod(seg, void *); - j = (*buff_data &0xf0 ); - pi.proto = (j ==0x40 ) ?0x0008 : - (j ==0x60 ) ?0xdd86 :0x00 ; +if (txq->type ==ETH_TUNTAP_TYPE_TUN ) { +/* +* TUN and TAP are created with IFF_NO_PI disabled. +* For TUN PMD this mandatory as fields are used by +* Kernel tun.c to determine whether its IP or non IP +* packets. +* +* The logic fetches the first byte of data from mbuf +* then compares whether its v4 or v6. If first byte +* is 4 or 6, then protocol field is updated. +*/ + char *buff_data = rte_pktmbuf_mtod(seg, void *); + j = (*buff_data &0xf0 ); + pi.proto = (j ==0x40 ) ?rte_cpu_to_be_16 (ETHER_TYPE_IPv4) : + (j ==0x60 ) ?rte_cpu_to_be_16 (ETHER_TYPE_IPv6) :0x00 ; + } iovecs[0 ].iov_base = π iovecs[0 ].iov_len =sizeof (pi);
@@ -928,6 +930,12 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)struct ifreq ifr;int ret; +if (pmd->type ==ETH_TUNTAP_TYPE_TUN ) { +TAP_LOG (ERR ,"%s: can't MAC address for TUN" , + dev->device->name); +return -ENOTSUP ; + } +if (is_zero_ether_addr (mac_addr)) {TAP_LOG (ERR ,"%s: can't set an empty MAC address" , dev->device->name);
@@ -1025,6 +1033,8 @@ tap_setup_queue(struct rte_eth_dev *dev, tx->mtu = &dev->data->mtu; rx->rxmode = &dev->data->dev_conf.rxmode; + tx->type = pmd->type; +return *fd; }
@@ -1342,7 +1352,8 @@ static const struct eth_dev_ops ops = {static int eth_dev_tap_create (struct rte_vdev_device *vdev,char *tap_name, -char *remote_iface,struct ether_addr *mac_addr) +char *remote_iface,struct ether_addr *mac_addr, +enum rte_tuntap_type type) {int numa_node =rte_socket_id ();struct rte_eth_dev *dev;
@@ -1364,6 +1375,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd = dev->data->dev_private; pmd->dev = dev;snprintf (pmd->name,sizeof (pmd->name),"%s" , tap_name); + pmd->type = type; pmd->ioctl_sock =socket (AF_INET ,SOCK_DGRAM ,0 );if (pmd->ioctl_sock ==-1 ) {
@@ -1400,7 +1412,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, pmd->txq[i].fd =-1 ; } -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {if (is_zero_ether_addr (mac_addr))eth_random_addr ((uint8_t *)&pmd->eth_addr);else
@@ -1423,7 +1435,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,if (tap_ioctl (pmd,SIOCSIFMTU , &ifr,1 ,LOCAL_AND_REMOTE ) <0 ) goto error_exit; -if (tap_type) { +if (pmd->type ==ETH_TUNTAP_TYPE_TAP ) {memset (&ifr,0 ,sizeof (struct ifreq )); ifr.ifr_hwaddr.sa_family =AF_LOCAL ; rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
@@ -1642,7 +1654,6 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)char tun_name[RTE_ETH_NAME_MAX_LEN ];char remote_iface[RTE_ETH_NAME_MAX_LEN ]; - tap_type =0 ;strcpy (tuntap_name,"TUN" ); name =rte_vdev_device_name (dev);
@@ -1673,7 +1684,8 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tun for %s as %s" , name, tun_name); - ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 ); + ret =eth_dev_tap_create (dev, tun_name, remote_iface,0 , +ETH_TUNTAP_TYPE_TUN ); leave:if (ret ==-1 ) {
@@ -1700,7 +1712,6 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)struct ether_addr user_mac = { .addr_bytes = {0 } };struct rte_eth_dev *eth_dev; - tap_type =1 ;strcpy (tuntap_name,"TAP" ); name =rte_vdev_device_name (dev);
@@ -1762,7 +1773,8 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)TAP_LOG (NOTICE ,"Initializing pmd_tap for %s as %s" , name, tap_name); - ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac); + ret =eth_dev_tap_create (dev, tap_name, remote_iface, &user_mac, +ETH_TUNTAP_TYPE_TAP ); leave:if (ret ==-1 ) {
@@ -1784,15 +1796,17 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)struct pmd_internals *internals;int i; -TAP_LOG (DEBUG ,"Closing TUN/TAP Ethernet device on numa %u" , -rte_socket_id ()); -/* find the ethdev entry */ eth_dev =rte_eth_dev_allocated (rte_vdev_device_name (dev));if (!eth_dev)return 0 ; internals = eth_dev->data->dev_private; + +TAP_LOG (DEBUG ,"Closing %s Ethernet device on numa %u" , + (internals->type ==ETH_TUNTAP_TYPE_TAP ) ?"TAP" :"TUN" , +rte_socket_id ()); +if (internals->nlsk_fd) {tap_flow_flush (eth_dev,NULL );tap_flow_implicit_flush (internals,NULL );
drivers/net/tap/rte_eth_tap.h +9 -0
@@ -23,6 +23,13 @@#define RTE_PMD_TAP_MAX_QUEUES 1#endif +enum rte_tuntap_type { +ETH_TUNTAP_TYPE_UNKNOWN , +ETH_TUNTAP_TYPE_TUN , +ETH_TUNTAP_TYPE_TAP , +ETH_TUNTAP_TYPE_MAX , +}; +struct pkt_stats {uint64_t opackets;/* Number of output packets */ uint64_t ipackets;/* Number of input packets */
@@ -48,6 +55,7 @@ struct rx_queue {struct tx_queue {int fd; +int type;/* Type field - TUN|TAP */ uint16_t *mtu;/* Pointer to MTU from dev_data */ uint16_t csum:1 ;/* Enable checksum offloading */ struct pkt_stats stats;/* Stats for this TX queue */
@@ -57,6 +65,7 @@ struct pmd_internals {struct rte_eth_dev *dev;/* Ethernet device. */ char remote_iface[RTE_ETH_NAME_MAX_LEN ];/* Remote netdevice name */ char name[RTE_ETH_NAME_MAX_LEN ];/* Internal Tap device name */ +int type;/* Type field - TUN|TAP */ struct ether_addr eth_addr;/* Mac address of the device port */ struct ifreq remote_initial_flags;/* Remote netdevice flags on init */ int remote_if_index;/* remote netdevice IF_INDEX */
Signature · 1 line
2.14.3
Re: [PATCH v5] net/tap: fix proto field for tun
Quoted 2 lines · Ferruh Yigit
From: Vipin Varghese <[email protected]>
Proto filed is fixed for tap, so title should be:
net/tap: fix proto field for tap
Will fix while merging.
Quoted 11 lines
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Fixes 204d026a3922 ("net/tap: support tun")Signed-off-by Vipin Varghese <[email protected]>Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Ophir Munk <[email protected]>
<...>
Ferruh Yigit
AppliedRe: [PATCH v5] net/tap: fix proto field for tun
Quoted 18 lines · Ferruh Yigit
Quoted 2 lines · Ferruh Yigit
From: Vipin Varghese <[email protected]>
Proto filed is fixed for tap, so title should be:
net/tap: fix proto field for tapWill fix while merging.
Quoted 9 lines
The TX function is shared between TAP and TUN PMD. Checking TUN-TAP type field will ensure the TAP PMD will always have protocol field as 0.
Fixes 204d026a3922 ("net/tap: support tun")Signed-off-by Vipin Varghese <[email protected]>Signed-off-by Ferruh Yigit <[email protected]>
Applied to dpdk-next-net/master, thanks.