net/virtio: add link speed tuning
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20191212085020eucas1p1be6d915a6610edf182d2ab0294c2a903@eucas1p1.samsung.com
PATCH 1/1 net/virtio: add link speed tuning
Some applications like pktgen use link_speed to calculate transmit rate. It limits outcome traffic to hardcoded 10G.
This patch makes link_speed configurable at compile time.
--- config/common_base | 1 + drivers/net/vhost/rte_eth_vhost.c | 2 +- drivers/net/virtio/virtio_ethdev.c | 20 ++++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-)
config/common_base +1 -0
@@ -433,6 +433,7 @@ CONFIG_RTE_LIBRTE_AVP_DEBUG_BUFFERS=n # Compile burst-oriented VIRTIO PMD driver # CONFIG_RTE_LIBRTE_VIRTIO_PMD=y +CONFIG_RTE_LIBRTE_VIRTIO_LINK_SPEED=10000 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_RX=n CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n
drivers/net/vhost/rte_eth_vhost.c +1 -1
@@ -115,7 +115,7 @@ static struct internal_list_head internal_list =static pthread_mutex_t internal_list_lock =PTHREAD_MUTEX_INITIALIZER ;static struct rte_eth_link pmd_link = { - .link_speed =10000 , + .link_speed =RTE_LIBRTE_VIRTIO_LINK_SPEED , .link_duplex =ETH_LINK_FULL_DUPLEX , .link_status =ETH_LINK_DOWN };
drivers/net/virtio/virtio_ethdev.c +16 -4
@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completmemset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =RTE_LIBRTE_VIRTIO_LINK_SPEED ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {
@@ -2426,9 +2426,21 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) {uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ - +#if RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_LINK_SPEED_20G + dev_info->speed_capa =ETH_LINK_SPEED_20G ; +#elif RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_SPEED_NUM_25G + dev_info->speed_capa =ETH_LINK_SPEED_25G ; +#elif RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_SPEED_NUM_40G + dev_info->speed_capa =ETH_LINK_SPEED_40G ; +#elif RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_SPEED_NUM_50G + dev_info->speed_capa =ETH_LINK_SPEED_50G ; +#elif RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_SPEED_NUM_56G + dev_info->speed_capa =ETH_LINK_SPEED_56G ; +#elif RTE_LIBRTE_VIRTIO_LINK_SPEED ==ETH_SPEED_NUM_100G + dev_info->speed_capa =ETH_LINK_SPEED_100G ; +#else + dev_info->speed_capa =ETH_LINK_SPEED_10G ; +#endif dev_info->max_rx_queues =RTE_MIN (hw->max_queue_pairs,VIRTIO_MAX_RX_QUEUES ); dev_info->max_tx_queues =
Signature · 1 line
2.17.1
v7 cover net/virtio: add link speed devarg
v7 chagnes:
* rebased to latest master
* added support of VIRTIO_NET_F_SPEED_DUPLEX
v6 changes:
* fix code style
v5 changes:
* fixed code style
* fixed commit message and logging text
v4 changes:
* link_speed renamed to speed devarg
* speed devarg is added to virtio-user driver
v3 changes:
* link_speed devarg is added to virtio documentation
PATCH v7 1/5 net/virtio: refactor devargs parsing
refactor vdpa specific devargs parsing to more generic way
--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +24 -10
@@ -1957,16 +1957,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) } static int vdpa_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +const char *value,void *ret_val) { -if (strcmp (value,"1" )) -return -1 ; +if (strcmp (value,"1" ) ==0 ) + *(int *)ret_val =1 ; +else + *(int *)ret_val =0 ;return 0 ; }static int -vdpa_mode_selected (struct rte_devargs *devargs) +virtio_dev_devargs_parse (struct rte_devargs *devargs,int *vdpa) {struct rte_kvargs *kvlist;const char *key ="vdpa" ;
@@ -1982,12 +1984,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)if (!rte_kvargs_count (kvlist, key)) goto exit; -/* vdpa mode selected when there's a key-value pair: vdpa=1 */ -if (rte_kvargs_process (kvlist, key, - vdpa_check_handler,NULL ) <0 ) { - goto exit; +if (vdpa) { +/* vdpa mode selected when there's a key-value pair: +* vdpa=1 +*/ + ret =rte_kvargs_process (kvlist, key, + vdpa_check_handler, vdpa); +if (ret <0 ) + goto exit; } - ret =1 ; + exit:rte_kvargs_free (kvlist);
@@ -1997,8 +2003,16 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +int vdpa =0 ; +int ret =0 ; + + ret =virtio_dev_devargs_parse (pci_dev->device.devargs, &vdpa); +if (ret <0 ) { +PMD_INIT_LOG (ERR ,"devargs parsing is failed" ); +return ret; + }/* virtio pmd skips probe if device needs to work in vdpa mode */ -if (vdpa_mode_selected (pci_dev->device.devargs)) +if (vdpa ==1 )return 1 ; return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
Signature · 1 line
2.17.1
PATCH v7 2/5 net/virtio: add link speed devarg
In reply to Ivan DyukovSome applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
--- doc/guides/nics/virtio.rst | 7 +++ drivers/net/virtio/virtio_ethdev.c | 97 +++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 89 insertions(+), 16 deletions(-)
doc/guides/nics/virtio.rst +7 -0
@@ -356,6 +356,13 @@ Below devargs are supported by the PCI virtio driver: a virtio device needs to work in vDPA mode. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device. Link speed is a part of + link status structure. It could be requested by application using + rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + Below devargs are supported by the virtio-user vdev: #. ``path``:
drivers/net/virtio/virtio_ethdev.c +81 -16
161 lines not on this page · raw message
drivers/net/virtio/virtio_pci.h +1 -0
@@ -259,6 +259,7 @@ struct virtio_hw {uint16_t port_id;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier; +uint32_t speed;/* link speed in MB */ uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
Signature · 1 line
2.17.1
PATCH v7 3/5 net/virtio-user: fix devargs parsing
In reply to Ivan Dyukovstrtoull returns 0 if it fails to parse input string. It's ignored in get_integer_arg.
This patch handles error cases for strtoull function.
--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +9 -4
@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ; + integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
Signature · 1 line
2.17.1
PATCH v7 4/5 net/virtio-user: adding link speed devarg
In reply to Ivan Dyukovvirtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call eth_virtio_dev_init function which init speed value.
eth_virtio_dev_init already is called from virtio_user_pmd_probe function. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/nics/virtio.rst +8 -0
@@ -410,6 +410,14 @@ Below devargs are supported by the virtio-user vdev: It is used to enable virtio device packed virtqueue feature. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device. Link speed is a part of + link status structure. It could be requested by application using + rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + + Virtio paths Selection and Usage --------------------------------
drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -450,6 +450,8 @@ static const char *valid_args[] = {VIRTIO_USER_ARG_IN_ORDER , #define VIRTIO_USER_ARG_PACKED_VQ "packed_vq"VIRTIO_USER_ARG_PACKED_VQ , +#define VIRTIO_USER_ARG_SPEED "speed" +VIRTIO_USER_ARG_SPEED , NULL };
@@ -782,4 +784,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,"server=<0|1> " "mrg_rxbuf=<0|1> " "in_order=<0|1> " - "packed_vq=<0|1>"); +"packed_vq=<0|1> " + "speed=<int>");
Signature · 1 line
2.17.1
PATCH v7 5/5 net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
In reply to Ivan DyukovThis patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver.
There are few ways to specify speed of the link:
'speed' devarg
negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX
The highest priority is devarg. If devarg is not specified, drivers tries to negotiate it from qemu.
--- drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++++++++++--- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_ethdev.c +23 -3
@@ -1662,7 +1662,8 @@ virtio_configure_intr(struct rte_eth_dev *dev)return 0 ; } - +#define SPEED_UNKNOWN 0xffffffff +#define DUPLEX_UNKNOWN 0xff/* reset device and renegotiate features if needed */ static int virtio_init_device (struct rte_eth_dev *eth_dev,uint64_t req_features)
@@ -1718,6 +1719,25 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (hw->speed ==SPEED_UNKNOWN ) { +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , duplex), + &config->duplex,sizeof (config->duplex)); + hw->speed = config->speed; + hw->duplex = config->duplex; + } + } +if (hw->speed ==SPEED_UNKNOWN ) + hw->speed =ETH_SPEED_NUM_10G ; +if (hw->duplex ==DUPLEX_UNKNOWN ) + hw->duplex =ETH_LINK_FULL_DUPLEX ; +PMD_INIT_LOG (DEBUG ,"link speed = %d, duplex = %d" , + hw->speed, hw->duplex);if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;
@@ -1865,7 +1885,7 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) {struct virtio_hw *hw = eth_dev->data->dev_private; -uint32_t speed =ETH_SPEED_NUM_10G ; +uint32_t speed =SPEED_UNKNOWN ;int ret;if (sizeof (struct virtio_net_hdr_mrg_rxbuf ) >RTE_PKTMBUF_HEADROOM ) {
@@ -2450,7 +2470,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completstruct virtio_hw *hw = dev->data->dev_private;memset (&link,0 ,sizeof (link)); - link.link_duplex =ETH_LINK_FULL_DUPLEX ; + link.link_duplex = hw->duplex; link.link_speed = hw->speed; link.link_autoneg =ETH_LINK_FIXED ;
drivers/net/virtio/virtio_ethdev.h +2 -1
@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
drivers/net/virtio/virtio_pci.h +16 -0
@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick
@@ -260,6 +263,7 @@ struct virtio_hw {uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier;uint32_t speed;/* link speed in MB */ +uint8_t duplex;uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
@@ -306,6 +310,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed; +/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
Signature · 1 line
2.17.1
v8 cover net/virtio: add link speed devarg
In reply to Ivan Dyukovv8 changes:
* fix code style
v7 chagnes:
* rebased to latest master
* added support of VIRTIO_NET_F_SPEED_DUPLEX
v6 changes:
* fix code style
v5 changes:
* fixed code style
* fixed commit message and logging text
v4 changes:
* link_speed renamed to speed devarg
* speed devarg is added to virtio-user driver
v3 changes:
* link_speed devarg is added to virtio documentation
PATCH v8 1/5 net/virtio: refactor devargs parsing
refactor vdpa specific devargs parsing to more generic way
--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +24 -10
@@ -1957,16 +1957,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) } static int vdpa_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +const char *value,void *ret_val) { -if (strcmp (value,"1" )) -return -1 ; +if (strcmp (value,"1" ) ==0 ) + *(int *)ret_val =1 ; +else + *(int *)ret_val =0 ;return 0 ; }static int -vdpa_mode_selected (struct rte_devargs *devargs) +virtio_dev_devargs_parse (struct rte_devargs *devargs,int *vdpa) {struct rte_kvargs *kvlist;const char *key ="vdpa" ;
@@ -1982,12 +1984,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)if (!rte_kvargs_count (kvlist, key)) goto exit; -/* vdpa mode selected when there's a key-value pair: vdpa=1 */ -if (rte_kvargs_process (kvlist, key, - vdpa_check_handler,NULL ) <0 ) { - goto exit; +if (vdpa) { +/* vdpa mode selected when there's a key-value pair: +* vdpa=1 +*/ + ret =rte_kvargs_process (kvlist, key, + vdpa_check_handler, vdpa); +if (ret <0 ) + goto exit; } - ret =1 ; + exit:rte_kvargs_free (kvlist);
@@ -1997,8 +2003,16 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +int vdpa =0 ; +int ret =0 ; + + ret =virtio_dev_devargs_parse (pci_dev->device.devargs, &vdpa); +if (ret <0 ) { +PMD_INIT_LOG (ERR ,"devargs parsing is failed" ); +return ret; + }/* virtio pmd skips probe if device needs to work in vdpa mode */ -if (vdpa_mode_selected (pci_dev->device.devargs)) +if (vdpa ==1 )return 1 ; return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
Signature · 1 line
2.17.1
PATCH v8 2/5 net/virtio: add link speed devarg
In reply to Ivan DyukovSome applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
--- doc/guides/nics/virtio.rst | 7 +++ drivers/net/virtio/virtio_ethdev.c | 97 +++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 89 insertions(+), 16 deletions(-)
doc/guides/nics/virtio.rst +7 -0
@@ -356,6 +356,13 @@ Below devargs are supported by the PCI virtio driver: a virtio device needs to work in vDPA mode. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device. Link speed is a part of + link status structure. It could be requested by application using + rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + Below devargs are supported by the virtio-user vdev: #. ``path``:
drivers/net/virtio/virtio_ethdev.c +81 -16
161 lines not on this page · raw message
drivers/net/virtio/virtio_pci.h +1 -0
@@ -259,6 +259,7 @@ struct virtio_hw {uint16_t port_id;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier; +uint32_t speed;/* link speed in MB */ uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v8 2/5] net/virtio: add link speed devarg
30/03/2020 09:57, Ivan Dyukov:
Quoted 5 lines
Some applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
Is it really a good idea to fake such information? Shouldn't it be managed differently in the application instead?
Re: [dpdk-dev] [PATCH v8 2/5] net/virtio: add link speed devarg
Hello Thomas,
01.04.2020 13:57, Thomas Monjalon пишет:
Quoted 11 lines
30/03/2020 09:57, Ivan Dyukov:
Quoted 5 lines
Some applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
Is it really a good idea to fake such information? Shouldn't it be managed differently in the application instead?
This is main stream of net devices. Device provides speed to application. Application calculates the packet rate. In case of virtio, speed is not limited by device. It could be specified by user. This patch just gives this posibility to user.
Best regards,
Ivan.
Re: [dpdk-dev] [PATCH v8 2/5] net/virtio: add link speed devarg
02/04/2020 11:18, Ivan Dyukov:
Quoted 14 lines
Hello Thomas,
01.04.2020 13:57, Thomas Monjalon пишет:
Quoted 11 lines
30/03/2020 09:57, Ivan Dyukov:
Quoted 5 lines
Some applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
Is it really a good idea to fake such information? Shouldn't it be managed differently in the application instead?
Quoted 4 lines
This is main stream of net devices. Device provides speed to application. Application calculates the packet rate. In case of virtio, speed is not limited by device. It could be specified by user. This patch just gives this posibility to user.
The other possibility is to return 0 meaning unknown speed. I don't see why this information should be saved in the driver space. The user can give this information to the application,
it would look more correct to me.
Note: the application is controlling the devargs passed to the driver, so it can intercept such information.
I understand it is easier to have the speed info at the same place in all cases. But it avoids differentiating what is a reliable info, and what is user-provided info.
Re: [dpdk-dev] [PATCH v8 2/5] net/virtio: add link speed devarg
02.04.2020 20:33, Thomas Monjalon пишет:
Quoted 15 lines
02/04/2020 11:18, Ivan Dyukov:
Quoted 14 lines
Hello Thomas,
01.04.2020 13:57, Thomas Monjalon пишет:
Quoted 11 lines
30/03/2020 09:57, Ivan Dyukov:
Quoted 5 lines
Some applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
Is it really a good idea to fake such information? Shouldn't it be managed differently in the application instead?
Quoted 5 lines
Quoted 4 lines
This is main stream of net devices. Device provides speed to application. Application calculates the packet rate. In case of virtio, speed is not limited by device. It could be specified by user. This patch just gives this posibility to user.
The other possibility is to return 0 meaning unknown speed.
Yep. Right. Linux kernel virtio is implemented same way. They return -1, if user haven't specified other.
Legacy dpdk virtio code was always returned 10G speed before my patchset and I just keep this value to
prevent breakages in applications like pktgen.
Quoted 1 line
I don't see why this information should be saved in the driver space.
The speed could be provided by qemu. Please see 5th patch in my patchset. It's not good idea to smash
this code accross application and driver side.
Quoted 4 lines
The user can give this information to the application,
it would look more correct to me.
Note: the application is controlling the devargs passed to the driver, so it can intercept such information.
These changes are specific only for virtio driver. If application will treat speed argument, then
it also should check that current driver is virtio and same code will be duplicated in every application.
Quoted 7 lines
I understand it is easier to have the speed info at the same place in all cases. But it avoids differentiating what is a reliable info, and what is user-provided info.
PATCH v8 3/5 net/virtio-user: fix devargs parsing
In reply to Ivan Dyukovstrtoull returns 0 if it fails to parse input string. It's ignored in get_integer_arg.
This patch handles error cases for strtoull function.
--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +9 -4
@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ; + integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
Signature · 1 line
2.17.1
PATCH v8 4/5 net/virtio-user: adding link speed devarg
In reply to Ivan Dyukovvirtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call eth_virtio_dev_init function which init speed value.
eth_virtio_dev_init already is called from virtio_user_pmd_probe function. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/nics/virtio.rst +8 -0
@@ -410,6 +410,14 @@ Below devargs are supported by the virtio-user vdev: It is used to enable virtio device packed virtqueue feature. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device. Link speed is a part of + link status structure. It could be requested by application using + rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + + Virtio paths Selection and Usage --------------------------------
drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -450,6 +450,8 @@ static const char *valid_args[] = {VIRTIO_USER_ARG_IN_ORDER , #define VIRTIO_USER_ARG_PACKED_VQ "packed_vq"VIRTIO_USER_ARG_PACKED_VQ , +#define VIRTIO_USER_ARG_SPEED "speed" +VIRTIO_USER_ARG_SPEED , NULL };
@@ -782,4 +784,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,"server=<0|1> " "mrg_rxbuf=<0|1> " "in_order=<0|1> " - "packed_vq=<0|1>"); +"packed_vq=<0|1> " + "speed=<int>");
Signature · 1 line
2.17.1
PATCH v8 5/5 net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
In reply to Ivan DyukovThis patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver.
There are few ways to specify speed of the link:
'speed' devarg
negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX
The highest priority is devarg. If devarg is not specified, drivers tries to negotiate it from qemu.
--- drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++++++++++--- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_ethdev.c +23 -3
@@ -1662,7 +1662,8 @@ virtio_configure_intr(struct rte_eth_dev *dev)return 0 ; } - +#define SPEED_UNKNOWN 0xffffffff +#define DUPLEX_UNKNOWN 0xff/* reset device and renegotiate features if needed */ static int virtio_init_device (struct rte_eth_dev *eth_dev,uint64_t req_features)
@@ -1718,6 +1719,25 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (hw->speed ==SPEED_UNKNOWN ) { +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , duplex), + &config->duplex,sizeof (config->duplex)); + hw->speed = config->speed; + hw->duplex = config->duplex; + } + } +if (hw->speed ==SPEED_UNKNOWN ) + hw->speed =ETH_SPEED_NUM_10G ; +if (hw->duplex ==DUPLEX_UNKNOWN ) + hw->duplex =ETH_LINK_FULL_DUPLEX ; +PMD_INIT_LOG (DEBUG ,"link speed = %d, duplex = %d" , + hw->speed, hw->duplex);if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;
@@ -1865,7 +1885,7 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) {struct virtio_hw *hw = eth_dev->data->dev_private; -uint32_t speed =ETH_SPEED_NUM_10G ; +uint32_t speed =SPEED_UNKNOWN ;int ret;if (sizeof (struct virtio_net_hdr_mrg_rxbuf ) >RTE_PKTMBUF_HEADROOM ) {
@@ -2450,7 +2470,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completstruct virtio_hw *hw = dev->data->dev_private;memset (&link,0 ,sizeof (link)); - link.link_duplex =ETH_LINK_FULL_DUPLEX ; + link.link_duplex = hw->duplex; link.link_speed = hw->speed; link.link_autoneg =ETH_LINK_FIXED ;
drivers/net/virtio/virtio_ethdev.h +2 -1
@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
drivers/net/virtio/virtio_pci.h +16 -0
@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick
@@ -260,6 +263,7 @@ struct virtio_hw {uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier;uint32_t speed;/* link speed in MB */ +uint8_t duplex;uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
@@ -306,6 +310,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed; +/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v8 0/5] net/virtio: add link speed devarg
In reply to Ivan DyukovHi Ivan,
Quoted 15 lines · Ivan Dyukov
v8 changes:
* fix code stylev7 chagnes:
* rebased to latest master
* added support ofVIRTIO_NET_F_SPEED_DUPLEXv6 changes:
* fix code stylev5 changes:
* fixed code style
* fixed commit message and logging text
Quoted 8 lines
v4 changes:
*link_speedrenamed to speed devarg
* speed devarg is added to virtio-user driverv3 changes:
*link_speeddevarg is added to virtio documentation
I finally applied this version, with adding the changes not related to ETH_SPEED_NUM_UNKNOWN from next revisions.
Once the ETH_SPEED_NUM_UNKNOWN series from Thomas is accepted (might only happen in v20.08), we'll adopt it in Virtio driver.
It is applied to dpdk-next-virtio/master, let me know if you spot any issue there.
Thanks again for adding VIRTIO_NET_F_SPEED_DUPLEX, Maxime
v9 cover net/virtio: add link speed devarg
In reply to Ivan Dyukovdoc/guides/nics/virtio.rst | 15 +++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 16 ++++++++++++++++ drivers/net/virtio/virtio_user_ethdev.c | 18 +++++++++++++----- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 6 files changed, 184 insertions(+), 39 deletions(-)
v9 chagnes:
* [PATCH 2/5] remove limited set of acceptable speeds [10G, 20G, 40G, 56G, 100G], now all natural numbers are acceptable
* [PATCH 2/5] returns speed_capa as maximum available capability for specified speed
* [PATCH 5/5] remove duplex negotiation
* [PATCH 5/5] set default speed to 0xffffffff
v8 changes:
* fix code style
v7 chagnes:
* rebased to latest master
* added support of VIRTIO_NET_F_SPEED_DUPLEX
v6 changes:
* fix code style
v5 changes:
* fixed code style
* fixed commit message and logging text
v4 changes:
* link_speed renamed to speed devarg
* speed devarg is added to virtio-user driver
v3 changes:
* link_speed devarg is added to virtio documentation
PATCH v9 1/5 net/virtio: refactor devargs parsing
refactor vdpa specific devargs parsing to more generic way
--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +24 -10
@@ -1957,16 +1957,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) } static int vdpa_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +const char *value,void *ret_val) { -if (strcmp (value,"1" )) -return -1 ; +if (strcmp (value,"1" ) ==0 ) + *(int *)ret_val =1 ; +else + *(int *)ret_val =0 ;return 0 ; }static int -vdpa_mode_selected (struct rte_devargs *devargs) +virtio_dev_devargs_parse (struct rte_devargs *devargs,int *vdpa) {struct rte_kvargs *kvlist;const char *key ="vdpa" ;
@@ -1982,12 +1984,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)if (!rte_kvargs_count (kvlist, key)) goto exit; -/* vdpa mode selected when there's a key-value pair: vdpa=1 */ -if (rte_kvargs_process (kvlist, key, - vdpa_check_handler,NULL ) <0 ) { - goto exit; +if (vdpa) { +/* vdpa mode selected when there's a key-value pair: +* vdpa=1 +*/ + ret =rte_kvargs_process (kvlist, key, + vdpa_check_handler, vdpa); +if (ret <0 ) + goto exit; } - ret =1 ; + exit:rte_kvargs_free (kvlist);
@@ -1997,8 +2003,16 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +int vdpa =0 ; +int ret =0 ; + + ret =virtio_dev_devargs_parse (pci_dev->device.devargs, &vdpa); +if (ret <0 ) { +PMD_INIT_LOG (ERR ,"devargs parsing is failed" ); +return ret; + }/* virtio pmd skips probe if device needs to work in vdpa mode */ -if (vdpa_mode_selected (pci_dev->device.devargs)) +if (vdpa ==1 )return 1 ; return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 1/5] net/virtio: refactor devargs parsing
Quoted 7 lines · Ivan Dyukov
refactor vdpa specific devargs parsing to more generic way
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
Thanks,
Maxime
PATCH v9 2/5 net/virtio: add link speed devarg
In reply to Ivan DyukovSome applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
--- doc/guides/nics/virtio.rst | 7 ++ drivers/net/virtio/virtio_ethdev.c | 108 ++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 100 insertions(+), 16 deletions(-)
doc/guides/nics/virtio.rst +7 -0
@@ -356,6 +356,13 @@ Below devargs are supported by the PCI virtio driver: a virtio device needs to work in vDPA mode. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + Below devargs are supported by the virtio-user vdev: #. ``path``:
drivers/net/virtio/virtio_ethdev.c +92 -16
172 lines not on this page · raw message
drivers/net/virtio/virtio_pci.h +1 -0
@@ -259,6 +259,7 @@ struct virtio_hw {uint16_t port_id;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier; +uint32_t speed;/* link speed in MB */ uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 2/5] net/virtio: add link speed devarg
Quoted 6 lines · Ivan Dyukov
Some applications like pktgen use link speed to calculate transmission rate. It limits outcome traffic to hardcoded 10G.
This patch adds speed devarg which allows to configure link speed of virtio device.
Quoted 7 lines
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/nics/virtio.rst | 7 ++ drivers/net/virtio/virtio_ethdev.c | 108 ++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 100 insertions(+), 16 deletions(-)
Thanks,
Maxime
PATCH v9 3/5 net/virtio-user: fix devargs parsing
In reply to Ivan Dyukovstrtoull returns 0 if it fails to parse input string. It's ignored in get_integer_arg.
This patch handles error cases for strtoull function.
--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +9 -4
@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ; + integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 3/5] net/virtio-user: fix devargs parsing
Quoted 4 lines · Ivan Dyukov
strtoull returns 0 if it fails to parse input string. It's ignored in
get_integer_arg.This patch handles error cases for strtoull function.
Quoted 23 lines
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/net/virtio/virtio_user_ethdev.c +2
-4@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ;
drivers/net/virtio/virtio_user_ethdev.c static int · line 493
Quoted 10 lines
drivers/net/virtio/virtio_user_ethdev.c +7
-0+ integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
I will fix the commit message when applying.
Thanks,
Maxime
PATCH v9 4/5 net/virtio-user: adding link speed devarg
In reply to Ivan Dyukovvirtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call eth_virtio_dev_init function which init speed value.
eth_virtio_dev_init already is called from virtio_user_pmd_probe function. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/nics/virtio.rst +8 -0
@@ -410,6 +410,14 @@ Below devargs are supported by the virtio-user vdev: It is used to enable virtio device packed virtqueue feature. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 10000 (10G)) + + Virtio paths Selection and Usage --------------------------------
drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -450,6 +450,8 @@ static const char *valid_args[] = {VIRTIO_USER_ARG_IN_ORDER , #define VIRTIO_USER_ARG_PACKED_VQ "packed_vq"VIRTIO_USER_ARG_PACKED_VQ , +#define VIRTIO_USER_ARG_SPEED "speed" +VIRTIO_USER_ARG_SPEED , NULL };
@@ -782,4 +784,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,"server=<0|1> " "mrg_rxbuf=<0|1> " "in_order=<0|1> " - "packed_vq=<0|1>"); +"packed_vq=<0|1> " + "speed=<int>");
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 4/5] net/virtio-user: adding link speed devarg
Quoted 8 lines · Ivan Dyukov
virtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call
eth_virtio_dev_initfunction which init speed value.
eth_virtio_dev_initalready is called fromvirtio_user_pmd_probefunction. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
Quoted 6 lines
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
Thanks,
Maxime
PATCH v9 5/5 net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
In reply to Ivan DyukovThis patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver. Set default speed to 0xffffffff and default duplex to 0xff
There are few ways to specify speed of the link:
'speed' devarg
negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX
The highest priority is devarg. If devarg is not specified, drivers tries to negotiate it from qemu.
--- doc/guides/nics/virtio.rst | 4 ++-- drivers/net/virtio/virtio_ethdev.c | 16 +++++++++++++++- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 5 files changed, 48 insertions(+), 17 deletions(-)
doc/guides/nics/virtio.rst +2 -2
@@ -361,7 +361,7 @@ Below devargs are supported by the PCI virtio driver: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown)) Below devargs are supported by the virtio-user vdev:
@@ -415,7 +415,7 @@ Below devargs are supported by the virtio-user vdev: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown)) Virtio paths Selection and Usage
drivers/net/virtio/virtio_ethdev.c +15 -1
@@ -1718,6 +1718,20 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +/* if speed is not specified in devargs */ +if (hw->speed ==ETH_SPEED_NUM_UNKNOWN ) { +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); + hw->speed = config->speed; + } + } + +PMD_INIT_LOG (DEBUG ,"link speed = %u%s" , + hw->speed, hw->speed ==ETH_SPEED_NUM_UNKNOWN ? +"(UNKNOWN)" :"" );if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;
@@ -1865,7 +1879,7 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) {struct virtio_hw *hw = eth_dev->data->dev_private; -uint32_t speed =ETH_SPEED_NUM_10G ; +uint32_t speed =ETH_SPEED_NUM_UNKNOWN ;int ret;if (sizeof (struct virtio_net_hdr_mrg_rxbuf ) >RTE_PKTMBUF_HEADROOM ) {
drivers/net/virtio/virtio_ethdev.h +2 -1
@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
drivers/net/virtio/virtio_pci.h +15 -0
@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick
@@ -306,6 +309,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed; +/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
lib/librte_ethdev/rte_ethdev.h +14 -13
@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v9 5/5] net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
Hi Ivan,
Quoted 5 lines · Ivan Dyukov
This patch adds a support of
VIRTIO_NET_F_SPEED_DUPLEXfeature for virtio driver. Set default speed to0xffffffffand default duplex to0xffThere are few ways to specify speed of the link:
s/few/two/
Quoted 2 lines
'speed' devarg
negotiate speed from qemu viaVIRTIO_NET_F_SPEED_DUPLEX
Thanks for taking care of that, I appreciate it.
It should be used soon with vDPA.
Quoted 17 lines
The highest priority is devarg. If devarg is not specified, drivers tries to negotiate it from qemu.
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/nics/virtio.rst | 4 ++-- drivers/net/virtio/virtio_ethdev.c | 16 +++++++++++++++- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 5 files changed, 48 insertions(+), 17 deletions(-)doc/guides/nics/virtio.rst +0
-0
doc/guides/nics/virtio.rst Below devargs are supported by the PCI virtio driver: · line 364
Quoted 5 lines
doc/guides/nics/virtio.rst +1
-1@@ -361,7 +361,7 @@ Below devargs are supported by the PCI virtio driver: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown))
I think the Default should be changed in the initial patch, not in the last one.
Quoted 83 lines
doc/guides/nics/virtio.rst +1
-1Below devargs are supported by the virtio-user vdev:@@ -415,7 +415,7 @@ Below devargs are supported by the virtio-user vdev: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown)) Virtio paths Selection and Usagedrivers/net/virtio/virtio_ethdev.c +15
-1@@ -1718,6 +1718,20 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +/* if speed is not specified in devargs */ +if (hw->speed ==ETH_SPEED_NUM_UNKNOWN ) { +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); + hw->speed = config->speed; + } + } + +PMD_INIT_LOG (DEBUG ,"link speed = %u%s" , + hw->speed, hw->speed ==ETH_SPEED_NUM_UNKNOWN ? +"(UNKNOWN)" :"" );if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;@@ -1865,7 +1879,7 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) {struct virtio_hw *hw = eth_dev->data->dev_private; -uint32_t speed =ETH_SPEED_NUM_10G ; +uint32_t speed =ETH_SPEED_NUM_UNKNOWN ;int ret;if (sizeof (struct virtio_net_hdr_mrg_rxbuf ) >RTE_PKTMBUF_HEADROOM ) {drivers/net/virtio/virtio_ethdev.h +2
-1@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \drivers/net/virtio/virtio_pci.h +8
-0@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick @@ -306,6 +309,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed;
drivers/net/virtio/virtio_pci.h struct virtio_net_config { · line 326
Quoted 10 lines
drivers/net/virtio/virtio_pci.h +7
-0+/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
Below change should be in a dedicated patch, and I would prefer it to be the first patch in the series.
Quoted 29 lines
lib/librte_ethdev/rte_ethdev.h +7
-13@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */
lib/librte_ethdev/rte_ethdev.h struct rte_eth_stats { · line 306
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +7
-0+#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
Thanks,
Maxime
v10 cover net/virtio: add link speed devarg
In reply to Ivan Dyukovdoc/guides/nics/virtio.rst | 15 +++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 16 ++++++++++++++++ drivers/net/virtio/virtio_user_ethdev.c | 18 +++++++++++++----- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 6 files changed, 183 insertions(+), 39 deletions(-)
v10 changes:
* [PATCH 1/6] unknown speed is moved to first patch
* [PATCH 3/6] rebased to latest changes
* [PATCH 4/6] updated commit message
* [PATCH 6/6] rebased to latest changes
v9 chagnes:
* [PATCH 2/5] remove limited set of acceptable speeds [10G, 20G, 40G, 56G, 100G], now all natural numbers are acceptable
* [PATCH 2/5] returns speed_capa as maximum available capability for specified speed
* [PATCH 5/5] remove duplex negotiation
* [PATCH 5/5] set default speed to 0xffffffff
v8 changes:
* fix code style
v7 chagnes:
* rebased to latest master
* added support of VIRTIO_NET_F_SPEED_DUPLEX
v6 changes:
* fix code style
v5 changes:
* fixed code style
* fixed commit message and logging text
v4 changes:
* link_speed renamed to speed devarg
* speed devarg is added to virtio-user driver
v3 changes:
* link_speed devarg is added to virtio documentation
PATCH v10 1/6 net/virtio: replace default virtio speed
This patch set speed to unknown
--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/virtio/virtio_ethdev.c +2 -2
@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completmemset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {
@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */ dev_info->max_rx_queues =RTE_MIN (hw->max_queue_pairs,VIRTIO_MAX_RX_QUEUES );
lib/librte_ethdev/rte_ethdev.h +14 -13
@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
Signature · 1 line
2.17.1
PATCH v10 2/6 net/virtio: refactor devargs parsing
In reply to Ivan Dyukovrefactor vdpa specific devargs parsing to more generic way
--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +24 -10
@@ -1957,16 +1957,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) } static int vdpa_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +const char *value,void *ret_val) { -if (strcmp (value,"1" )) -return -1 ; +if (strcmp (value,"1" ) ==0 ) + *(int *)ret_val =1 ; +else + *(int *)ret_val =0 ;return 0 ; }static int -vdpa_mode_selected (struct rte_devargs *devargs) +virtio_dev_devargs_parse (struct rte_devargs *devargs,int *vdpa) {struct rte_kvargs *kvlist;const char *key ="vdpa" ;
@@ -1982,12 +1984,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)if (!rte_kvargs_count (kvlist, key)) goto exit; -/* vdpa mode selected when there's a key-value pair: vdpa=1 */ -if (rte_kvargs_process (kvlist, key, - vdpa_check_handler,NULL ) <0 ) { - goto exit; +if (vdpa) { +/* vdpa mode selected when there's a key-value pair: +* vdpa=1 +*/ + ret =rte_kvargs_process (kvlist, key, + vdpa_check_handler, vdpa); +if (ret <0 ) + goto exit; } - ret =1 ; + exit:rte_kvargs_free (kvlist);
@@ -1997,8 +2003,16 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +int vdpa =0 ; +int ret =0 ; + + ret =virtio_dev_devargs_parse (pci_dev->device.devargs, &vdpa); +if (ret <0 ) { +PMD_INIT_LOG (ERR ,"devargs parsing is failed" ); +return ret; + }/* virtio pmd skips probe if device needs to work in vdpa mode */ -if (vdpa_mode_selected (pci_dev->device.devargs)) +if (vdpa ==1 )return 1 ; return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
Signature · 1 line
2.17.1
PATCH v10 3/6 net/virtio: add link speed devarg
In reply to Ivan DyukovDefault value of link speed is 0xffffffff (Unknown)
This patch adds speed devarg which allows to configure link speed of virtio device.
--- doc/guides/nics/virtio.rst | 7 ++ drivers/net/virtio/virtio_ethdev.c | 107 ++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 99 insertions(+), 16 deletions(-)
doc/guides/nics/virtio.rst +7 -0
@@ -356,6 +356,13 @@ Below devargs are supported by the PCI virtio driver: a virtio device needs to work in vDPA mode. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 0xffffffff (Unknown)) + Below devargs are supported by the virtio-user vdev: #. ``path``:
drivers/net/virtio/virtio_ethdev.c +91 -16
165 lines not on this page · raw message
drivers/net/virtio/virtio_pci.h +1 -0
@@ -259,6 +259,7 @@ struct virtio_hw {uint16_t port_id;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier; +uint32_t speed;/* link speed in MB */ uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
Signature · 1 line
2.17.1
PATCH v10 4/6 net/virtio-user: fix devargs parsing
In reply to Ivan Dyukovstrtoull returns 0 if it fails to parse input string. It's ignored in get_integer_arg.
This patch handles error cases for strtoull function.
--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +9 -4
@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ; + integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
Signature · 1 line
2.17.1
PATCH v10 5/6 net/virtio-user: adding link speed devarg
In reply to Ivan Dyukovvirtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call eth_virtio_dev_init function which init speed value.
eth_virtio_dev_init already is called from virtio_user_pmd_probe function. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/nics/virtio.rst +8 -0
@@ -410,6 +410,14 @@ Below devargs are supported by the virtio-user vdev: It is used to enable virtio device packed virtqueue feature. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 0xffffffff (Unknown)) + + Virtio paths Selection and Usage --------------------------------
drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -450,6 +450,8 @@ static const char *valid_args[] = {VIRTIO_USER_ARG_IN_ORDER , #define VIRTIO_USER_ARG_PACKED_VQ "packed_vq"VIRTIO_USER_ARG_PACKED_VQ , +#define VIRTIO_USER_ARG_SPEED "speed" +VIRTIO_USER_ARG_SPEED , NULL };
@@ -782,4 +784,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,"server=<0|1> " "mrg_rxbuf=<0|1> " "in_order=<0|1> " - "packed_vq=<0|1>"); +"packed_vq=<0|1> " + "speed=<int>");
Signature · 1 line
2.17.1
PATCH v10 6/6 net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
In reply to Ivan DyukovThis patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver.
There are two ways to specify speed of the link:
* 'speed' devarg
* negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX
The highest priority is devarg. If devarg is not specified, driver tries to negotiate it from qemu.
--- drivers/net/virtio/virtio_ethdev.c | 14 ++++++++++++++ drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +14 -0
@@ -1718,6 +1718,20 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +/* if speed is not specified in devargs */ +if (hw->speed ==ETH_SPEED_NUM_UNKNOWN ) { +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); + hw->speed = config->speed; + } + } + +PMD_INIT_LOG (DEBUG ,"link speed = %u%s" , + hw->speed, hw->speed ==ETH_SPEED_NUM_UNKNOWN ? +"(UNKNOWN)" :"" );if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;
drivers/net/virtio/virtio_ethdev.h +2 -1
@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
drivers/net/virtio/virtio_pci.h +15 -0
@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick
@@ -306,6 +309,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed; +/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
Signature · 1 line
2.17.1
v11 cover net/virtio: add link speed devarg
In reply to Ivan Dyukovdoc/guides/nics/virtio.rst | 15 +++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 16 ++++++++++++++++ drivers/net/virtio/virtio_user_ethdev.c | 18 +++++++++++++----- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 6 files changed, 183 insertions(+), 39 deletions(-)
v11 changes:
* [PATCH 6/6] changed sign-off
v10 changes:
* [PATCH 1/6] unknown speed is moved to first patch
* [PATCH 3/6] rebased to latest changes
* [PATCH 4/6] updated commit message
* [PATCH 6/6] rebased to latest changes
v9 chagnes:
* [PATCH 2/5] remove limited set of acceptable speeds [10G, 20G, 40G, 56G, 100G], now all natural numbers are acceptable
* [PATCH 2/5] returns speed_capa as maximum available capability for specified speed
* [PATCH 5/5] remove duplex negotiation
* [PATCH 5/5] set default speed to 0xffffffff
v8 changes:
* fix code style
v7 chagnes:
* rebased to latest master
* added support of VIRTIO_NET_F_SPEED_DUPLEX
v6 changes:
* fix code style
v5 changes:
* fixed code style
* fixed commit message and logging text
v4 changes:
* link_speed renamed to speed devarg
* speed devarg is added to virtio-user driver
v3 changes:
* link_speed devarg is added to virtio documentation
PATCH v11 1/6 net/virtio: replace default virtio speed
This patch set speed to unknown
--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/virtio/virtio_ethdev.c +2 -2
@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completmemset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {
@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */ dev_info->max_rx_queues =RTE_MIN (hw->max_queue_pairs,VIRTIO_MAX_RX_QUEUES );
lib/librte_ethdev/rte_ethdev.h +14 -13
@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 1/6] net/virtio: replace default virtio speed
Quoted 59 lines · Ivan Dyukov
This patch set speed to unknown
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)drivers/net/virtio/virtio_ethdev.c +2
-2@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_completmemset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */ dev_info->max_rx_queues =RTE_MIN (hw->max_queue_pairs,VIRTIO_MAX_RX_QUEUES );lib/librte_ethdev/rte_ethdev.h +7
-13@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */
lib/librte_ethdev/rte_ethdev.h struct rte_eth_stats { · line 306
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +7
-0+#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
I actually meant to have the rte_ethdev.h change in a dedicated patch, as it is in a different subsystem. Someone could want to backport only the lib change without touching the Virtio driver.
If OK for you, I can do that while applying.
Thanks,
Maxime
Re: [dpdk-dev] [PATCH v11 1/6] net/virtio: replace default virtio speed
In reply to Ivan DyukovQuoted 27 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Thursday, April 16, 2020 7:53 AMThis patch set speed to unknown
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)drivers/net/virtio/virtio_ethdev.c +0
-0@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev,
__rte_unusedintwait_to_completdrivers/net/virtio/virtio_ethdev.c +1
-1memset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {
drivers/net/virtio/virtio_ethdev.c virtio_dev_info_get(struct rte_eth_dev *dev, · line 2431
Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +1
-1@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */
If you indicate that the NIC supports Auto Negotiation here, then I suggest that you also change the link status as follows:
- link.link_autoneg = ETH_LINK_FIXED;
+ link.link_autoneg = ETH_LINK_AUTONEG;
I considered the opposite change, but if we define that the underlying environment determines the actual speed, then Auto Negotiation seems more correct than Fixed speed.
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v11 1/6] net/virtio: replace default virtio speed
Quoted 39 lines · Morten Brørup
Quoted 27 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Thursday, April 16, 2020 7:53 AMThis patch set speed to unknown
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)drivers/net/virtio/virtio_ethdev.c +0
-0@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev,
__rte_unusedintwait_to_completdrivers/net/virtio/virtio_ethdev.c +1
-1memset (&link,0 ,sizeof (link)); link.link_duplex =ETH_LINK_FULL_DUPLEX ; - link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {drivers/net/virtio/virtio_ethdev.c virtio_dev_info_get(struct rte_eth_dev *dev, · line 2431
Quoted 6 lines
drivers/net/virtio/virtio_ethdev.c +1
-1@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private; - dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */ If you indicate that the NIC supports Auto Negotiation here, then I suggest that you also change the link status as follows:
- link.link_autoneg =ETH_LINK_FIXED;
+ link.link_autoneg =ETH_LINK_AUTONEG;
Quoted 1 line
I considered the opposite change, but if we define that the underlying environment determines the actual speed, then Auto Negotiation seems more correct than Fixed speed.
That's a valid point.
Thank you Morten for spotting this!
Ivan, I can do the change while applying if you are fine with it.
Thanks,
Maxime
Quoted 5 lines
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v11 1/6] net/virtio: replace default virtio speed
Hi Maxime, Morten,
Thank you for comments. I'll prepare one more revision of the change.
Best regards,
Ivan
16.04.2020 14:58, Maxime Coquelin пишет:
Quoted 55 lines · Morten Brørup
Quoted 31 lines
Quoted 31 lines
From: Ivan Dyukov [mailto:[email protected]]
Sent: Thursday, April 16, 2020 7:53 AMThis patch set speed to unknown
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-)drivers/net/virtio/virtio_ethdev.c +0
-0@@ -2371,7 +2371,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev,
__rte_unusedintwait_to_completmemset(&link, 0, sizeof(link)); link.link_duplex = ETH_LINK_FULL_DUPLEX;drivers/net/virtio/virtio_ethdev.c +1
-1- link.link_speed =ETH_SPEED_NUM_10G ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; link.link_autoneg =ETH_LINK_FIXED ;if (!hw->started) {@@ -2427,7 +2427,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)uint64_t tso_mask, host_features;struct virtio_hw *hw = dev->data->dev_private;Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 2430
Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +1
-1- dev_info->speed_capa =ETH_LINK_SPEED_10G ;/* fake value */ + dev_info->speed_capa =ETH_LINK_SPEED_AUTONEG ;/* fake value */ If you indicate that the NIC supports Auto Negotiation here, then I suggest that you also change the link status as follows:
- link.link_autoneg =ETH_LINK_FIXED;
+ link.link_autoneg =ETH_LINK_AUTONEG;I considered the opposite change, but if we define that the underlying environment determines the actual speed, then Auto Negotiation seems more correct than Fixed speed.
That's a valid point.
Thank you Morten for spotting this!Ivan, I can do the change while applying if you are fine with it.
Thanks,
MaximeQuoted 5 lines
Med venlig hilsen / kind regards
- Morten Brørup
PATCH v11 2/6 net/virtio: refactor devargs parsing
In reply to Ivan Dyukovrefactor vdpa specific devargs parsing to more generic way
--- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +24 -10
@@ -1957,16 +1957,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) } static int vdpa_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +const char *value,void *ret_val) { -if (strcmp (value,"1" )) -return -1 ; +if (strcmp (value,"1" ) ==0 ) + *(int *)ret_val =1 ; +else + *(int *)ret_val =0 ;return 0 ; }static int -vdpa_mode_selected (struct rte_devargs *devargs) +virtio_dev_devargs_parse (struct rte_devargs *devargs,int *vdpa) {struct rte_kvargs *kvlist;const char *key ="vdpa" ;
@@ -1982,12 +1984,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)if (!rte_kvargs_count (kvlist, key)) goto exit; -/* vdpa mode selected when there's a key-value pair: vdpa=1 */ -if (rte_kvargs_process (kvlist, key, - vdpa_check_handler,NULL ) <0 ) { - goto exit; +if (vdpa) { +/* vdpa mode selected when there's a key-value pair: +* vdpa=1 +*/ + ret =rte_kvargs_process (kvlist, key, + vdpa_check_handler, vdpa); +if (ret <0 ) + goto exit; } - ret =1 ; + exit:rte_kvargs_free (kvlist);
@@ -1997,8 +2003,16 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,struct rte_pci_device *pci_dev) { +int vdpa =0 ; +int ret =0 ; + + ret =virtio_dev_devargs_parse (pci_dev->device.devargs, &vdpa); +if (ret <0 ) { +PMD_INIT_LOG (ERR ,"devargs parsing is failed" ); +return ret; + }/* virtio pmd skips probe if device needs to work in vdpa mode */ -if (vdpa_mode_selected (pci_dev->device.devargs)) +if (vdpa ==1 )return 1 ; return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
Signature · 1 line
2.17.1
PATCH v11 3/6 net/virtio: add link speed devarg
In reply to Ivan DyukovDefault value of link speed is 0xffffffff (Unknown)
This patch adds speed devarg which allows to configure link speed of virtio device.
--- doc/guides/nics/virtio.rst | 7 ++ drivers/net/virtio/virtio_ethdev.c | 107 ++++++++++++++++++++++++----- drivers/net/virtio/virtio_pci.h | 1 + 3 files changed, 99 insertions(+), 16 deletions(-)
doc/guides/nics/virtio.rst +7 -0
@@ -356,6 +356,13 @@ Below devargs are supported by the PCI virtio driver: a virtio device needs to work in vDPA mode. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 0xffffffff (Unknown)) + Below devargs are supported by the virtio-user vdev: #. ``path``:
drivers/net/virtio/virtio_ethdev.c +91 -16
165 lines not on this page · raw message
drivers/net/virtio/virtio_pci.h +1 -0
@@ -259,6 +259,7 @@ struct virtio_hw {uint16_t port_id;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];uint32_t notify_off_multiplier; +uint32_t speed;/* link speed in MB */ uint8_t *isr;uint16_t *notify_base;struct virtio_pci_common_cfg *common_cfg;
Signature · 1 line
2.17.1
PATCH v11 4/6 net/virtio-user: fix devargs parsing
In reply to Ivan Dyukovstrtoull returns 0 if it fails to parse input string. It's ignored in get_integer_arg.
This patch handles error cases for strtoull function.
--- drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user_ethdev.c +9 -4
@@ -477,12 +477,17 @@ static int get_integer_arg(const char *key __rte_unused, const char *value, void *extra_args) { + uint64_t integer = 0;if (!value || !extra_args)return -EINVAL ; - - *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); - -return 0 ; + errno =0 ; + integer =strtoull (value,NULL ,0 ); +/* extra_args keeps default value, it should be replaced +* only in case of successful parsing of the 'value' arg +*/ +if (errno ==0 ) + *(uint64_t *)extra_args = integer; +return -errno; } static struct rte_eth_dev *
Signature · 1 line
2.17.1
PATCH v11 5/6 net/virtio-user: adding link speed devarg
In reply to Ivan Dyukovvirtio driver already parses speed devarg. virtio-user should add it to list of valid devargs and call eth_virtio_dev_init function which init speed value.
eth_virtio_dev_init already is called from virtio_user_pmd_probe function. The only change is required to enable speed devargs:
adding speed to list of valid devargs.
--- doc/guides/nics/virtio.rst | 8 ++++++++ drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/nics/virtio.rst +8 -0
@@ -410,6 +410,14 @@ Below devargs are supported by the virtio-user vdev: It is used to enable virtio device packed virtqueue feature. (Default: 0 (disabled)) +#. ``speed``: + + It is used to specify link speed of virtio device, in units of 1Mb. + Link speed is a part of link status structure. It could be requested + by application using rte_eth_link_get_nowait function. + (Default: 0xffffffff (Unknown)) + + Virtio paths Selection and Usage --------------------------------
drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -450,6 +450,8 @@ static const char *valid_args[] = {VIRTIO_USER_ARG_IN_ORDER , #define VIRTIO_USER_ARG_PACKED_VQ "packed_vq"VIRTIO_USER_ARG_PACKED_VQ , +#define VIRTIO_USER_ARG_SPEED "speed" +VIRTIO_USER_ARG_SPEED , NULL };
@@ -782,4 +784,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_virtio_user,"server=<0|1> " "mrg_rxbuf=<0|1> " "in_order=<0|1> " - "packed_vq=<0|1>"); +"packed_vq=<0|1> " + "speed=<int>");
Signature · 1 line
2.17.1
PATCH v11 6/6 net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX
In reply to Ivan DyukovThis patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver.
There are two ways to specify speed of the link:
* 'speed' devarg
* negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX
The highest priority is devarg. If devarg is not specified, driver tries to negotiate it from qemu.
--- drivers/net/virtio/virtio_ethdev.c | 14 ++++++++++++++ drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +14 -0
@@ -1718,6 +1718,20 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0 ], hw->mac_addr[1 ], hw->mac_addr[2 ], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); +if (vtpci_with_feature (hw,VIRTIO_NET_F_SPEED_DUPLEX )) { + config = &local_config; +/* if speed is not specified in devargs */ +if (hw->speed ==ETH_SPEED_NUM_UNKNOWN ) { +vtpci_read_dev_config (hw, + offsetof(struct virtio_net_config , speed), + &config->speed,sizeof (config->speed)); + hw->speed = config->speed; + } + } + +PMD_INIT_LOG (DEBUG ,"link speed = %u%s" , + hw->speed, hw->speed ==ETH_SPEED_NUM_UNKNOWN ? +"(UNKNOWN)" :"" );if (vtpci_with_feature (hw,VIRTIO_NET_F_CTRL_VQ )) { config = &local_config;
drivers/net/virtio/virtio_ethdev.h +2 -1
@@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
drivers/net/virtio/virtio_pci.h +15 -0
@@ -141,6 +141,9 @@ struct virtnet_ctl;*/ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 +/* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick
@@ -306,6 +309,18 @@ struct virtio_net_config {uint16_t status;uint16_t max_virtqueue_pairs;uint16_t mtu; +/* +* speed, in units of 1Mb. All values 0 to INT_MAX are legal. +* Any other value stands for unknown. +*/ +uint32_t speed; +/* +* 0x00 - half duplex +* 0x01 - full duplex +* Any other value stands for unknown. +*/ +uint8_t duplex; + } __attribute__((packed));/*
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v12 1/7 ethdev: added UNKNOWN speed value
UNKNOWN speed equals to 0xffffffff
--- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
lib/librte_ethdev/rte_ethdev.h +14 -13
@@ -287,19 +287,20 @@ struct rte_eth_stats {/** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0/**< Not defined */ -#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0/**< Not defined */ +#define ETH_SPEED_NUM_10M 10/**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100/**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000/**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500/**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000/**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000/**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000/**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000/**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000/**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffff
[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */
This approach is being rejected in another thread:
http://inbox.dpdk.org/dev/[email protected]/
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
Hello Everyone,
Ook. I can take care about examples updates. link_speed could be printed in following way:
("link speed %u%s", link_speed, link_speed ==ETH_SPEED_NUM_UNKNOWN?"(UNKNOWN)":"")
Please let me know if you have any objections.
There are about 47 cases.
$ grep -rn link_speed examples/ app/ doc/ | wc -l 47
Thanks,
Ivan
17.04.2020 01:14, Thomas Monjalon пишет:
Quoted 14 lines
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffff[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */This approach is being rejected in another thread:
https://protect2.fireeye.com/url?k=ed2d2a70-b0fe73ce-ed2ca13f-0cc47a31ba82-80584d32127c24cd&q=1&u=http%3A%2F%2Finbox.dpdk.org%2Fdev%2F42de4bd1-0a6c-6591-cd27-67ce692fabc9%40intel.com%2F
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
Hi Ferruh & Andrew,
Quoted 9 lines · Ivan Dyukov
Hello Everyone,
Ook. I can take care about examples updates.
link_speedcould be printed in following way:
("link speed %u%s",link_speed,link_speed==ETH_SPEED_NUM_UNKNOWN?"(UNKNOWN)":"")Please let me know if you have any objections.
Quoted 18 lines
There are about 47 cases.
$ grep -rn link_speed examples/ app/ doc/ | wc -l 47Thanks,
Ivan
17.04.2020 01:14, Thomas Monjalon пишет:Quoted 10 lines
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffff[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */This approach is being rejected in another thread:
https://protect2.fireeye.com/url?k=ed2d2a70-b0fe73ce-ed2ca13f-0cc47a31ba82-80584d32127c24cd&q=1&u=http%3A%2F%2Finbox.dpdk.org%2Fdev%2F42de4bd1-0a6c-6591-cd27-67ce692fabc9%40intel.com%2F
Would that work for you?
I would need your ACK before applying the series (which I planned to do for -rc1).
Thanks in advance,
Maxime
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
Quoted 26 lines · Maxime Coquelin
Hi Ferruh & Andrew,
Quoted 23 lines · Ivan Dyukov
Hello Everyone,
Ook. I can take care about examples updates.
link_speedcould be printed in following way:
("link speed %u%s",link_speed,link_speed==ETH_SPEED_NUM_UNKNOWN?"(UNKNOWN)":"")Please let me know if you have any objections.
There are about 47 cases.
$ grep -rn link_speed examples/ app/ doc/ | wc -l 47Thanks,
Ivan
17.04.2020 01:14, Thomas Monjalon пишет:Quoted 6 lines
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffff
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */This approach is being rejected in another thread:
https://protect2.fireeye.com/url?k=ed2d2a70-b0fe73ce-ed2ca13f-0cc47a31ba82-80584d32127c24cd&q=1&u=http%3A%2F%2Finbox.dpdk.org%2Fdev%2F42de4bd1-0a6c-6591-cd27-67ce692fabc9%40intel.com%2FWould that work for you?
I would need your ACK before applying the series (which I planned to do for -rc1).
Hi Maxime,
There is another patch from Thomas that targets this change only [1], and it is waiting for change request, because the scope of the change is larger than just defining a new macro, documentation & sample/test applications should be aware of this new speed definition.
Instead of this patch, this patchset can wait [1] as dependency.
Or if this patchset is urgent, perhaps this patch can go in as it as and Thomas' patch can replace it later with full implementation, if Thomas agrees.
And not sure if it is good idea, but perhaps this "unknown speed' can be used local to virtio until [1] becomes ready, though I am for having this as last option.
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
Hi Ferruh,
Quoted 43 lines · Ferruh Yigit
Quoted 26 lines · Maxime Coquelin
Hi Ferruh & Andrew,
Quoted 23 lines · Ivan Dyukov
Hello Everyone,
Ook. I can take care about examples updates.
link_speedcould be printed in following way:
("link speed %u%s",link_speed,link_speed==ETH_SPEED_NUM_UNKNOWN?"(UNKNOWN)":"")Please let me know if you have any objections.
There are about 47 cases.
$ grep -rn link_speed examples/ app/ doc/ | wc -l 47Thanks,
Ivan
17.04.2020 01:14, Thomas Monjalon пишет:Quoted 6 lines
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffffQuoted 8 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */This approach is being rejected in another thread:
https://protect2.fireeye.com/url?k=ed2d2a70-b0fe73ce-ed2ca13f-0cc47a31ba82-80584d32127c24cd&q=1&u=http%3A%2F%2Finbox.dpdk.org%2Fdev%2F42de4bd1-0a6c-6591-cd27-67ce692fabc9%40intel.com%2FWould that work for you?
I would need your ACK before applying the series (which I planned to do for -rc1).Hi Maxime,
There is another patch from Thomas that targets this change only [1], and it is waiting for change request, because the scope of the change is larger than just defining a new macro, documentation & sample/test applications should be aware of this new speed definition.
Quoted 7 lines
Instead of this patch, this patchset can wait [1] as dependency.
Or if this patchset is urgent, perhaps this patch can go in as it as and Thomas' patch can replace it later with full implementation, if Thomas agrees.
And not sure if it is good idea, but perhaps this "unknown speed' can be used local to virtio until [1] becomes ready, though I am for having this as last option.
I was replying to my mail after discussing with Thomas.
I agree Thomas's series is better, and now understand this is an API change that was not announced.
What I propose it basically to apply Ivan's v8 with a few fixes on top that he did. It means that if no value is set in the NIC or not value defined as devargs, then 10G will be picked as default.
Note that the 10G value is the one currently displayyed, without Ivan's series, so it seems a reasonable temporary solution.
Thanks,
Maxime
Quoted 3 lines
Re: [dpdk-dev] [PATCH v12 1/7] ethdev: added UNKNOWN speed value
17/04/2020 17:54, Maxime Coquelin:
Quoted 59 lines
Hi Ferruh,
Quoted 43 lines · Ferruh Yigit
Quoted 26 lines · Maxime Coquelin
Hi Ferruh & Andrew,
Quoted 23 lines · Ivan Dyukov
Hello Everyone,
Ook. I can take care about examples updates.
link_speedcould be printed in following way:
("link speed %u%s",link_speed,link_speed==ETH_SPEED_NUM_UNKNOWN?"(UNKNOWN)":"")Please let me know if you have any objections.
There are about 47 cases.
$ grep -rn link_speed examples/ app/ doc/ | wc -l 47Thanks,
Ivan
17.04.2020 01:14, Thomas Monjalon пишет:Quoted 6 lines
Hi,
Please look at an update below from ethdev co-maintainers.
16/04/2020 14:42, Ivan Dyukov:
Quoted 1 line
UNKNOWN speed equals to
0xffffffffQuoted 8 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 1 line
+#define
ETH_SPEED_NUM_UNKNOWN0xffffffff/**< Unknown */This approach is being rejected in another thread:
https://protect2.fireeye.com/url?k=ed2d2a70-b0fe73ce-ed2ca13f-0cc47a31ba82-80584d32127c24cd&q=1&u=http%3A%2F%2Finbox.dpdk.org%2Fdev%2F42de4bd1-0a6c-6591-cd27-67ce692fabc9%40intel.com%2FWould that work for you?
I would need your ACK before applying the series (which I planned to do for -rc1).Hi Maxime,
There is another patch from Thomas that targets this change only [1], and it is waiting for change request, because the scope of the change is larger than just defining a new macro, documentation & sample/test applications should be aware of this new speed definition.
Quoted 7 lines
Instead of this patch, this patchset can wait [1] as dependency.
Or if this patchset is urgent, perhaps this patch can go in as it as and Thomas' patch can replace it later with full implementation, if Thomas agrees.
And not sure if it is good idea, but perhaps this "unknown speed' can be used local to virtio until [1] becomes ready, though I am for having this as last option.
I was replying to my mail after discussing with Thomas.
I agree Thomas's series is better, and now understand this is an API change that was not announced.
Quoted 6 lines
What I propose it basically to apply Ivan's v8 with a few fixes on top that he did. It means that if no value is set in the NIC or not value defined as devargs, then 10G will be picked as default.
Note that the 10G value is the one currently displayyed, without Ivan's series, so it seems a reasonable temporary solution.
I am OK with the suggested solution for virtio in 20.05.
Any help to implement and document unknown speed is welcome. I won't work on it during the next 2 weeks, so feel free to take over my patch and make it complete for 20.08.
cover ethdev: allow unknown link speed
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH 1/6 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link informations, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -301,6 +301,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_50G 50000/**< 50 Gbps */ #define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2260,15 +2261,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link informations written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2277,15 +2279,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link informations written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 1/6] ethdev: allow unknown link speed
Quoted 16 lines · Ivan Dyukov
From: Thomas Monjalon <[email protected]>
When querying the link informations, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)This API update is making explicit that the link speed information is optional.
The valueETH_SPEED_NUM_NONE(0) was already part of the API. The valueETH_SPEED_NUM_UNKNOWN(infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
Quoted 3 lines
Suggested-by Morten Brørup <[email protected]>Suggested-by Benoit Ganne <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
PATCH 2/6 app/procinfo: fix printf format specifier for uint
In reply to Ivan Dyukov--- app/proc-info/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/proc-info/main.c +1 -1
@@ -685,7 +685,7 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { - printf("\t -- link speed %d duplex %d," + printf("\t -- link speed %u duplex %d," " auto neg %d status %d\n", link.link_speed, link.link_duplex,
Signature · 1 line
2.17.1
PATCH 3/6 ethdev: remove extra 'new line' in output
In reply to Ivan Dyukov--- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +1 -1
@@ -3005,7 +3005,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. speed %u Mbps- %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
app/test/test_pmd_perf.c +1 -1
@@ -151,7 +151,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex"));if (link_mbps ==0 ) link_mbps = link.link_speed; }else
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 3/6] ethdev: remove extra 'new line' in output
Quoted 25 lines · Ivan Dyukov
Signed-off-by Ivan Dyukov <[email protected]>--- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +1
-1@@ -3005,7 +3005,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. speed %u Mbps- %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;app/test/test_pmd_perf.c +0
-0
app/test/test_pmd_perf.c check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) · line 157
Quoted 8 lines
app/test/test_pmd_perf.c +1
-1@@ -151,7 +151,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex"));if (link_mbps ==0 ) link_mbps = link.link_speed; }else
I think Fixes: tag is required here.
Re: [dpdk-dev] [PATCH v1 3/6] ethdev: remove extra 'new line' in output
01/05/2020 15:15, Andrew Rybchenko:
Quoted 38 lines · Ivan Dyukov
Quoted 25 lines
Signed-off-by Ivan Dyukov <[email protected]>--- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +1
-1@@ -3005,7 +3005,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. speed %u Mbps- %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;app/test/test_pmd_perf.c +0
-0app/test/test_pmd_perf.c check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) · line 157
Quoted 8 lines
app/test/test_pmd_perf.c +1
-1@@ -151,7 +151,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex"));if (link_mbps ==0 ) link_mbps = link.link_speed; }else I think Fixes: tag is required here.
Quoted 1 line
Acked-by Andrew Rybchenko <[email protected]>
Yes please, we would like to backport it.
Re: [dpdk-dev] [PATCH v1 3/6] ethdev: remove extra 'new line' in output
07.05.2020 13:28, Thomas Monjalon пишет:
Quoted 38 lines
01/05/2020 15:15, Andrew Rybchenko:
Quoted 37 lines · Ivan Dyukov
Quoted 25 lines
Signed-off-by Ivan Dyukov <[email protected]>--- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)app/test-pmd/testpmd.c +1
-1@@ -3005,7 +3005,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. speed %u Mbps- %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;app/test/test_pmd_perf.c +0
-0app/test/test_pmd_perf.c check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) · line 157
Quoted 8 lines
app/test/test_pmd_perf.c +1
-1@@ -151,7 +151,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex"));if (link_mbps ==0 ) link_mbps = link.link_speed; }else I think Fixes: tag is required here.
Quoted 5 lines
Quoted 1 line
Acked-by Andrew Rybchenko <[email protected]>Yes please, we would like to backport it.
Ok. I'll make separate patch for that. There are about 24 same 'copy/paste' in example folder.
PATCH 1/3 ethdev: remove extra 'new line' in output
In reply to Thomas MonjalonThis is testpmd part of new line cleanup
--- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +1 -1
@@ -3005,7 +3005,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. speed %u Mbps- %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
app/test/test_pmd_perf.c +1 -1
@@ -151,7 +151,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex"));if (link_mbps ==0 ) link_mbps = link.link_speed; }else
Signature · 1 line
2.17.1
PATCH 2/3 examples: remove extra 'new line' in output
This patch removes extra 'new line' in few app examples
--- examples/ip_fragmentation/main.c | 2 +- examples/ipv4_multicast/main.c | 2 +- examples/l2fwd/main.c | 2 +- examples/l3fwd/main.c | 2 +- examples/link_status_interrupt/main.c | 2 +- examples/multi_process/client_server_mp/mp_server/init.c | 2 +- examples/multi_process/symmetric_mp/main.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
examples/ip_fragmentation/main.c +1 -1
@@ -617,7 +617,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up .Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/ipv4_multicast/main.c +1 -1
@@ -596,7 +596,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l2fwd/main.c +1 -1
@@ -478,7 +478,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l3fwd/main.c +1 -1
@@ -838,7 +838,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps -%s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/link_status_interrupt/main.c +1 -1
@@ -500,7 +500,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/multi_process/client_server_mp/mp_server/init.c +1 -1
@@ -209,7 +209,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Mbps - %s\n" , ports->id[portid], (unsigned )link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", (uint8_t)ports->id[portid]);
examples/multi_process/symmetric_mp/main.c +1 -1
@@ -389,7 +389,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
Signature · 1 line
2.17.1
PATCH 3/3 examples: remove extra 'new line' in output
In reply to Ivan DyukovThis patch removes extra 'new line' in few app examples
--- examples/ioat/ioatfwd.c | 2 +- examples/ip_reassembly/main.c | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 2 +- examples/kni/main.c | 2 +- examples/l2fwd-crypto/main.c | 2 +- examples/l2fwd-event/main.c | 2 +- examples/l2fwd-jobstats/main.c | 2 +- examples/l2fwd-keepalive/main.c | 2 +- examples/l3fwd-acl/main.c | 2 +- examples/l3fwd-power/main.c | 2 +- examples/performance-thread/l3fwd-thread/main.c | 2 +- examples/qos_sched/init.c | 2 +- examples/server_node_efd/server/init.c | 2 +- examples/vm_power_manager/main.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-)
examples/ioat/ioatfwd.c +1 -1
@@ -718,7 +718,7 @@ check_link_status(uint32_t port_mask)"Port %d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); link_status =1 ; }else printf ("Port %d Link Down\n" , portid);
examples/ip_reassembly/main.c +1 -1
@@ -736,7 +736,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/ipsec-secgw/ipsec-secgw.c +1 -1
@@ -1800,7 +1800,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up - speed %u Mbps -%s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/kni/main.c +1 -1
@@ -683,7 +683,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up - speed %uMbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l2fwd-crypto/main.c +1 -1
@@ -1756,7 +1756,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l2fwd-event/main.c +1 -1
@@ -394,7 +394,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,"Port%d Link Up. Speed %u Mbps - %s\n" , port_id, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", port_id);continue ;
examples/l2fwd-jobstats/main.c +1 -1
@@ -710,7 +710,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l2fwd-keepalive/main.c +1 -1
@@ -475,7 +475,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l3fwd-acl/main.c +1 -1
@@ -1839,7 +1839,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/l3fwd-power/main.c +1 -1
@@ -1959,7 +1959,7 @@ check_all_ports_link_status(uint32_t port_mask)"Mbps - %s\n" , (uint8_t )portid, (unsigned )link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", (uint8_t)portid);
examples/performance-thread/l3fwd-thread/main.c +1 -1
@@ -3457,7 +3457,7 @@ check_all_ports_link_status(uint32_t port_mask)"Port%d Link Up. Speed %u Mbps - %s\n" , portid, link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", portid);continue ;
examples/qos_sched/init.c +1 -1
@@ -164,7 +164,7 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)printf (" Link Up - speed %u Mbps - %s\n" , (uint32_t ) link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex\n" )); + ("full-duplex" ) : ("half-duplex" )); }else {printf (" Link Down\n" ); }
examples/server_node_efd/server/init.c +1 -1
@@ -272,7 +272,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) info->id[portid], link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", info->id[portid]);
examples/vm_power_manager/main.c +1 -1
@@ -272,7 +272,7 @@ check_all_ports_link_status(uint32_t port_mask)"Mbps - %s\n" , (uint16_t )portid, (unsigned int )link.link_speed, (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex") : ("half-duplex\n")); + ("full-duplex") : ("half-duplex")); else printf("Port %d Link Down\n", (uint16_t)portid);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 1/3] ethdev: remove extra 'new line' in output
In reply to Ivan Dyukov07/05/2020 20:26, Ivan Dyukov:
Quoted 8 lines
This is testpmd part of new line cleanup
Fixes 002ade70e9 (app/test: measure cycles per packet in Rx/Tx)Fixes ce8d561418 (app/testpmd: add port configuration settings)Acked-by Andrew Rybchenko <[email protected]>Signed-off-by Ivan Dyukov <[email protected]>
Series applied, thanks
PATCH 4/6 app/testpmd: remove extra type conversions
In reply to Ivan Dyukovlink_speed is uint32_t. There are no needs to convert it.
--- app/test-pmd/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/config.c +2 -2
@@ -577,7 +577,7 @@ port_infos_display(portid_t port_id)printf ("\nmemory allocation on the socket: %u" ,port->socket_id);printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); +printf ("Link speed: %u Mbps\n" , link.link_speed);printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));
@@ -727,7 +727,7 @@ port_summary_display(portid_t port_id) mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int) link.link_speed); + link.link_speed); }void
Signature · 1 line
2.17.1
PATCH 5/6 doc: update sample app with unknown speed
In reply to Ivan Dyukov--- doc/guides/sample_app_ug/link_status_intr.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
doc/guides/sample_app_ug/link_status_intr.rst +2 -1
@@ -177,7 +177,8 @@ An example callback function that has been written as indicated below. printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, + printf("Port %d Link Up - speed %u%s - %s\n\n", port_id, (unsigned)link.link_speed, + (link.link_speed == UINT32_MAX) ? ("(UNKNOWN)") : (" Mbps"), (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); } else printf("Port %d Link Down\n\n", port_id);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
Quoted 11 lines · Ivan Dyukov
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0
doc/guides/sample_app_ug/link_status_intr.rst An example callback function that has been written as indicated below. · line 184
Quoted 9 lines
doc/guides/sample_app_ug/link_status_intr.rst +2
-1@@ -177,7 +177,8 @@ An example callback function that has been written as indicated below. printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, + printf("Port %d Link Up - speed %u%s - %s\n\n", port_id, (unsigned)link.link_speed, + (link.link_speed == UINT32_MAX) ? ("(UNKNOWN)") : (" Mbps"), (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); } else printf("Port %d Link Down\n\n", port_id);
I think that 0 looks nicer than UINT32_MAX when printed as integer keeping in mind that it is unknown.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 22 lines · Ivan Dyukov
Quoted 21 lines
Signed-off-by Ivan Dyukov <[email protected]>---
doc/guides/sample_app_ug/link_status_intr.rst| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :
(" Mbps"),
Quoted 9 lines
Quoted 5 lines
(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.
zero will mislead developers about real value of the link_speed. therefore we should print real value of the speed or print nothing. e.g.
if (link.link_speed == UINT32_MAX)
printf("Port %d Link Up - speed UNKNOWN - %s\n\n", port_id, (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
else
printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id,
link.link_speed,
(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
Quoted 41 lines · Ivan Dyukov
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 21 lines · Ivan Dyukov
Quoted 20 lines
Signed-off-by Ivan Dyukov <[email protected]>---
doc/guides/sample_app_ug/link_status_intr.rst| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed ==
UINT32_MAX)printf("Port %d Link Up - speed UNKNOWN - %s\n\n",
port_id, (link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
else
Quoted 5 lines
printf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
I'm not sure about 0 to be misleading, but it could be. Above definitely will look better in stdout.
The only problem is code duplication in many-many places. May be add simple function in ethdev to do it and use it in all examples?
Please, wait more feedback before doing it.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
Hi,
Sharing an observation especially with Fortville (X710), if the port is not started the advertised speed is not max speed (10000 or 40000). Hence would cross check on link_state be useful before display?
Quoted 64 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Andrew Rybchenko
Sent: Sunday, May 3, 2020 7:27 PM
To: Ivan Dyukov <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speedQuoted 42 lines · Ivan Dyukov
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 22 lines · Ivan Dyukov
Quoted 21 lines
Signed-off-by Ivan Dyukov <[email protected]>---
doc/guides/sample_app_ug/link_status_intr.rst| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n", +port_id,
(unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed ==
UINT32_MAX)printf("Port %d Link Up - speed UNKNOWN - %s\n\n",
port_id, (link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
elseQuoted 5 lines
printf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));I'm not sure about 0 to be misleading, but it could be.
Above definitely will look better in stdout.
The only problem is code duplication in many-many places.
May be add simple function in ethdev to do it and use it in all examples?Please, wait more feedback before doing it.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
In reply to Andrew Rybchenko03.05.2020 16:57, Andrew Rybchenko пишет:
Quoted 45 lines · Ivan Dyukov
Quoted 44 lines
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 21 lines · Ivan Dyukov
Quoted 20 lines
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed ==
UINT32_MAX)printf("Port %d Link Up - speed UNKNOWN - %s\n\n",
port_id, (link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
elseprintf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,
Quoted 7 lines
Quoted 2 lines
(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));I'm not sure about 0 to be misleading, but it could be. Above definitely will look better in stdout.
The only problem is code duplication in many-many places. May be add simple function in ethdev to do it and use it in all examples?
Also we can introduce new printf specifier using register_printf_specifier function or even rewrite %u which will print UNKNOWN in case ofUINT32_MAX.
Quoted 4 lines
Please, wait more feedback before doing it.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
Quoted 53 lines · Ivan Dyukov
03.05.2020 16:57, Andrew Rybchenko пишет:
Quoted 45 lines · Ivan Dyukov
Quoted 44 lines
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 21 lines · Ivan Dyukov
Quoted 20 lines
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed ==
UINT32_MAX)printf("Port %d Link Up - speed UNKNOWN - %s\n\n",
port_id, (link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
elseprintf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,Quoted 7 lines
Quoted 2 lines
(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));I'm not sure about 0 to be misleading, but it could be. Above definitely will look better in stdout.
The only problem is code duplication in many-many places. May be add simple function in ethdev to do it and use it in all examples?
Quoted 4 lines
Also we can introduce new printf specifier using
register_printf_specifierfunction or even rewrite %u which will print UNKNOWN in case ofUINT32_MAX.
True, but it is too libc-specific as far as I know.
Quoted 3 lines
Quoted 3 lines
Please, wait more feedback before doing it.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
04.05.2020 18:54, Andrew Rybchenko пишет:
Quoted 54 lines · Ivan Dyukov
Quoted 53 lines
03.05.2020 16:57, Andrew Rybchenko пишет:
Quoted 52 lines · Ivan Dyukov
Quoted 38 lines
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 21 lines · Ivan Dyukov
Quoted 20 lines
Signed-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed == UINT32_MAX) printf("Port %d Link Up - speed UNKNOWN - %s\n\n", port_id, (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?Quoted 8 lines
("full-duplex") : ("half-duplex"));
elseprintf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?("full-duplex") : ("half-duplex"));
I'm not sure about 0 to be misleading, but it could be. Above definitely will look better in stdout.
The only problem is code duplication in many-many places. May be add simple function in ethdev to do it and use it in all examples?
Quoted 5 lines
Quoted 4 lines
Also we can introduce new printf specifier using
register_printf_specifierfunction or even rewrite %u which will print UNKNOWN in case ofUINT32_MAX.True, but it is too libc-specific as far as I know.
Yep, it has portability issues. It's GNU C extension. https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Please, wait more feedback before doing it.
Re: [dpdk-dev] [PATCH v1 5/6] doc: update sample app with unknown speed
In reply to Andrew RybchenkoQuoted 42 lines · Andrew Rybchenko
Quoted 41 lines · Ivan Dyukov
01.05.2020 16:28, Andrew Rybchenko пишет:
Quoted 21 lines · Ivan Dyukov
Quoted 20 lines
Signed-off-by Ivan Dyukov <[email protected]>---
doc/guides/sample_app_ug/link_status_intr.rst| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0@@ -177,7 +177,8 @@ An example callback function that has beenwritten as indicated below.
printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret));
} else if (link.link_status) {
- printf("Port %d Link Up - speed %u Mbps - %s\n\n",port_id, (unsigned)link.link_speed,
+ printf("Port %d Link Up - speed %u%s - %s\n\n",port_id, (unsigned)link.link_speed,
+ (link.link_speed ==UINT32_MAX) ? ("(UNKNOWN)") :Quoted 9 lines
Quoted 6 lines
(" Mbps"),
(link.link_duplex ==ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex"));
} else
printf("Port %d Link Down\n\n", port_id);I think that 0 looks nicer than
UINT32_MAXwhen printed as integer keeping in mind that it is unknown.zero will mislead developers about real value of the
link_speed. therefore we should print real value of the speed or print nothing. e.g.if (link.link_speed ==
UINT32_MAX)printf("Port %d Link Up - speed UNKNOWN - %s\n\n",
port_id, (link.link_duplex ==ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
else
Quoted 8 lines
Quoted 5 lines
printf("Port %d Link Up - speed %u Mbps - %s\n\n",
port_id,
link.link_speed,(link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));I'm not sure about 0 to be misleading, but it could be. Above definitely will look better in stdout.
+1
Quoted 1 line
The only problem is code duplication in many-many places.
+1
What about print signed value, so it will be "-1 UNKNOWN", not too bad as log but concern is if it is confusing again?
Quoted 5 lines
May be add simple function in ethdev to do it and use it in all examples?
Please, wait more feedback before doing it.
PATCH 6/6 ethdev: UNKNOWN link speed print format
In reply to Ivan Dyukov--- app/proc-info/main.c | 7 ++++++- app/test-pipeline/init.c | 14 ++++++++------ app/test-pmd/config.c | 10 ++++++---- app/test-pmd/testpmd.c | 4 +++- app/test/test_pmd_perf.c | 4 +++- 5 files changed, 26 insertions(+), 13 deletions(-)
app/proc-info/main.c +6 -1
@@ -685,10 +685,15 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %u duplex %d," +printf ("\t -- link speed %u%s duplex %d%s," " auto neg %d status %d\n" , link.link_speed, + (link.link_speed ==UINT32_MAX ) ? + ("(UNKNOWN)" ) : (" Mbps" ), link.link_duplex, + (link.link_duplex == +ETH_LINK_FULL_DUPLEX ) ? + ("(full)" ) : ("(half)" ), link.link_autoneg, link.link_status); }
app/test-pipeline/init.c +8 -6
@@ -173,12 +173,14 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , - port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - +if (link.link_speed ==UINT32_MAX ) +RTE_LOG (INFO ,USER1 ,"Port %u (UNKNOWN Gbps) %s\n" , + port, link.link_status ?"UP" :"DOWN" ); +else +RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , + port, + link.link_speed /1000 , + link.link_status ?"UP" :"DOWN" );if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +6 -4
@@ -577,7 +577,8 @@ port_infos_display(portid_t port_id)printf ("\nmemory allocation on the socket: %u" ,port->socket_id);printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , link.link_speed); +printf ("Link speed: %u%s\n" , link.link_speed, + (link.link_speed ==UINT32_MAX ) ? ("(UNKNOWN)" ) : (" Mbps" ));printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));
@@ -722,12 +723,13 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %u%s\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - link.link_speed); + link.link_speed, + (link.link_speed ==UINT32_MAX ) ? ("(UNKNOWN)" ) : (" Mbps" )); }void
@@ -3787,7 +3789,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=UINT32_MAX && rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +3 -1
@@ -3002,8 +3002,10 @@ check_all_ports_link_status(uint32_t port_mask)if (print_flag ==1 ) {if (link.link_status)printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , +"Port%d Link Up. speed %u%s- %s\n" , portid, link.link_speed, + (link.link_speed ==UINT32_MAX ) ? + ("(UNKNOWN)" ) : (" Mbps" ), (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));else
app/test/test_pmd_perf.c +3 -1
@@ -148,8 +148,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)if (print_flag ==1 ) {if (link.link_status) {printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , +"Port%d Link Up. Speed %u%s - %s\n" , portid, link.link_speed, + (link.link_speed ==UINT32_MAX ) ? + ("(UNKNOWN)" ) : (" Mbps" ), (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? ("full-duplex" ) : ("half-duplex" ));if (link_mbps ==0 )
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 0/6] ethdev: allow unknown link speed
In reply to Ivan DyukovQuoted 6 lines · Ivan Dyukov
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Also I can see there are some physical PMDs that are using 'ETH_SPEED_NUM_NONE' as unknown, can we fix them as part of this set?
Re: [dpdk-dev] [PATCH v1 0/6] ethdev: allow unknown link speed
06.05.2020 20:42, Ferruh Yigit пишет:
Quoted 10 lines · Ivan Dyukov
Quoted 6 lines
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Also I can see there are some physical PMDs that are using '
ETH_SPEED_NUM_NONE' as unknown, can we fix them as part of this set?
Initially, we had a plan to use UNKNOWN only for virtual devices.
Thomas, could you please comment this?
Re: [dpdk-dev] [PATCH v1 0/6] ethdev: allow unknown link speed
07/05/2020 10:53, Ivan Dyukov:
Quoted 8 lines
06.05.2020 20:42, Ferruh Yigit пишет:
Quoted 7 lines · Ivan Dyukov
Quoted 6 lines
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Quoted 6 lines
Quoted 3 lines
Also I can see there are some physical PMDs that are using '
ETH_SPEED_NUM_NONE' as unknown, can we fix them as part of this set?Initially, we had a plan to use UNKNOWN only for virtual devices.
Thomas, could you please comment this?
No I think UNKNOWN must be used also for HW devices which are not able to provide a speed value.
In mlx5 case, it can be used to return the link status (up/down) even if speed query is failing (it happens with buggy kernel version).
Re: [dpdk-dev] [PATCH v1 0/6] ethdev: allow unknown link speed
07.05.2020 13:31, Thomas Monjalon пишет:
Quoted 12 lines
07/05/2020 10:53, Ivan Dyukov:
Quoted 11 lines
06.05.2020 20:42, Ferruh Yigit пишет:
Quoted 10 lines · Ivan Dyukov
Quoted 6 lines
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Also I can see there are some physical PMDs that are using '
ETH_SPEED_NUM_NONE' as unknown, can we fix them as part of this set?
Quoted 9 lines
Quoted 3 lines
Initially, we had a plan to use UNKNOWN only for virtual devices.
Thomas, could you please comment this?
No I think UNKNOWN must be used also for HW devices which are not able to provide a speed value.
In mlx5 case, it can be used to return the link status (up/down) even if speed query is failing (it happens with buggy kernel version).
Ok. Is ETH_SPEED_NUM_NONE still needed then? could it be replaced by UNKNOWN everywhere?
Quoted 1 line
Re: [dpdk-dev] [PATCH v1 0/6] ethdev: allow unknown link speed
Quoted 16 lines · Ivan Dyukov
07.05.2020 13:31, Thomas Monjalon пишет:
Quoted 15 lines
07/05/2020 10:53, Ivan Dyukov:
Quoted 14 lines
06.05.2020 20:42, Ferruh Yigit пишет:
Quoted 10 lines · Ivan Dyukov
Quoted 6 lines
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
Also I can see there are some physical PMDs that are using '
ETH_SPEED_NUM_NONE' as unknown, can we fix them as part of this set?Initially, we had a plan to use UNKNOWN only for virtual devices.
Thomas, could you please comment this?
Quoted 8 lines
Quoted 6 lines
No I think UNKNOWN must be used also for HW devices which are not able to provide a speed value.
In mlx5 case, it can be used to return the link status (up/down) even if speed query is failing (it happens with buggy kernel version).
Ok. Is
ETH_SPEED_NUM_NONEstill needed then? could it be replaced by UNKNOWN everywhere?
It is needed, please don't replace it.
For example when the link is down, device speed is 'ETH_SPEED_NUM_NONE', but when the link is up but driver doesn't know the speed, for some reason, device speed is 'ETH_SPEED_NUM_UNKNOWN'.
First patch says 'ETH_SPEED_NUM_UNKNOWN' is for two cases:
- speed is not known by the driver
- device is virtual
We are talking about first case above.
v2 cover ethdev: allow unknown link speed
In reply to Ivan Dyukovapp/proc-info/main.c | 15 +++++++++------ app/test-pipeline/init.c | 11 ++++++----- app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 10 ++++++---- app/test/test_pmd_perf.c | 10 ++++++---- doc/guides/sample_app_ug/link_status_intr.rst | 6 ++++-- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- drivers/net/ice/ice_ethdev.c | 5 ++++- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- lib/librte_ethdev/rte_ethdev.c | 39 +++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++++++++++++++++++++++++++++---------- 12 files changed, 137 insertions(+), 51 deletions(-)
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v2 1/7 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v2 2/7 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- lib/librte_ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 31 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)
lib/librte_ethdev/rte_ethdev.c +39 -0
@@ -2385,6 +2385,45 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +void +rte_eth_link_prepare_text (struct rte_eth_link *eth_link,uint32_t speed_unit, +struct rte_eth_link_text *link_text) +{ +uint32_t link_speed =0 ; +/* prepare link speed */ +if (eth_link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) +memcpy (link_text->link_speed,"unknown" ,sizeof ("unknown" )); +else { +if (speed_unit ==ETH_SPEED_UNIT_GBPS ) + link_speed = eth_link->link_speed /1000 ; +else + link_speed = eth_link->link_speed; +snprintf (link_text->link_speed,sizeof (link_text->link_speed), +"%u" , link_speed); + } +/* prepare link duplex */ +if (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) +memcpy (link_text->link_duplex,"full-duplex" , +sizeof ("full-duplex" )); +else +memcpy (link_text->link_duplex,"half-duplex" , +sizeof ("half-duplex" )); +/* prepare autoneg */ +if (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) +memcpy (link_text->link_autoneg,"autoneg" , +sizeof ("autoneg" )); +else +memcpy (link_text->link_autoneg,"fixed" , +sizeof ("fixed" )); +/* prepare status */ +if (eth_link->link_status ==ETH_LINK_DOWN ) +memcpy (link_text->link_status,"down" , +sizeof ("down" )); +else +memcpy (link_text->link_status,"up" , +sizeof ("up" )); +} +int rte_eth_stats_get (uint16_t port_id,struct rte_eth_stats *stats) {
lib/librte_ethdev/rte_ethdev.h +31 -0
@@ -316,6 +316,19 @@ struct rte_eth_link { uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ }__rte_aligned (8 );/**< aligned for atomic64 read/write */ +/** +* Link speed units +*/ +#define ETH_SPEED_UNIT_GBPS 0 +#define ETH_SPEED_UNIT_MBPS 1 + + +struct rte_eth_link_text { +char link_speed[14 ];/** link speed */ +char link_duplex[12 ];/** full-duplex or half-duplex */ +char link_autoneg[8 ];/** autoneg or fixed */ +char link_status[5 ];/** down or up */ +};/* Utility constants */ #define ETH_LINK_HALF_DUPLEX 0/**< Half-duplex connection (see link_duplex). */ #define ETH_LINK_FULL_DUPLEX 1/**< Full-duplex connection (see link_duplex). */
@@ -2295,6 +2308,24 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* Format link status to textual representation. speed_unit is used to convert +* link_speed to specified unit. Also this function threats a special +* ETH_SPEED_NUM_UNKNOWN value of link_speed and return 'UNKNOWN' speed +* in this case. +* +* @param link +* Link status provided by rte_eth_link_get function +* @param speed_unit +* Target units for the speed. Following values are available: +* - ETH_SPEED_UNIT_GBPS +* - ETH_SPEED_UNIT_MBPS +* @param link_text +* A pointer to an *rte_eth_link_text* structure to be filled with +* textual representation of device status +*/ +void rte_eth_link_prepare_text (struct rte_eth_link *link,uint32_t speed_unit, +struct rte_eth_link_text *link_text);/** * Retrieve the general I/O statistics of an Ethernet device. *
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 2/7] ethdev: add a link status textrepresentation
Quoted 125 lines
From: dev [mailto:[email protected]] On Behalf Of Ivan Dyukov
Sent: Tuesday, May 26, 2020 9:10 PMThis commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 31 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)lib/librte_ethdev/rte_ethdev.c +14
-0@@ -2385,6 +2385,45 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +void +rte_eth_link_prepare_text (struct rte_eth_link *eth_link,uint32_t speed_unit, +struct rte_eth_link_text *link_text) +{ +uint32_t link_speed =0 ; +/* prepare link speed */ +if (eth_link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) +memcpy (link_text->link_speed,"unknown" ,sizeof ("unknown" )); +else { +if (speed_unit ==ETH_SPEED_UNIT_GBPS ) + link_speed = eth_link->link_speed /1000 ; +else + link_speed = eth_link->link_speed; + snprintf(link_text->link_speed, sizeof(link_text-Quoted 1 line
link_speed),lib/librte_ethdev/rte_ethdev.c +25
-0+ "%u", link_speed); + } +/* prepare link duplex */ +if (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) +memcpy (link_text->link_duplex,"full-duplex" , +sizeof ("full-duplex" )); +else +memcpy (link_text->link_duplex,"half-duplex" , +sizeof ("half-duplex" )); +/* prepare autoneg */ +if (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) +memcpy (link_text->link_autoneg,"autoneg" , +sizeof ("autoneg" )); +else +memcpy (link_text->link_autoneg,"fixed" , +sizeof ("fixed" )); +/* prepare status */ +if (eth_link->link_status ==ETH_LINK_DOWN ) +memcpy (link_text->link_status,"down" , +sizeof ("down" )); +else +memcpy (link_text->link_status,"up" , +sizeof ("up" )); +} +int rte_eth_stats_get (uint16_t port_id,struct rte_eth_stats *stats) {lib/librte_ethdev/rte_ethdev.h +13
-0@@ -316,6 +316,19 @@ struct rte_eth_link { uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ }__rte_aligned (8 );/**< aligned for atomic64 read/write */ +/** +* Link speed units +*/ +#define ETH_SPEED_UNIT_GBPS 0 +#define ETH_SPEED_UNIT_MBPS 1 + + +struct rte_eth_link_text { +char link_speed[14 ];/** link speed */ +char link_duplex[12 ];/** full-duplex or half-duplex */ +char link_autoneg[8 ];/** autoneg or fixed */ +char link_status[5 ];/** down or up */ +};/* Utility constants */ #define ETH_LINK_HALF_DUPLEX 0/**< Half-duplex connection (see
link_duplex). */
#defineETH_LINK_FULL_DUPLEX1 /**< Full-duplex connection (seelink_duplex). */lib/librte_ethdev/rte_ethdev.h +2
-0@@ -2295,6 +2308,24 @@ int rte_eth_link_get(uint16_t port_id, structrte_eth_link *link); */ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* Format link status to textual representation. speed_unit is used to convert
+ *link_speedto specified unit. Also this function threats a special
+ *ETH_SPEED_NUM_UNKNOWNvalue oflink_speedand return 'UNKNOWN' speed
+ * in this case.
+ *
+ * @param link
+ * Link status provided byrte_eth_link_getfunction
+ * @paramspeed_unit
+ * Target units for the speed. Following values are available:
+ * -ETH_SPEED_UNIT_GBPS
+ * -ETH_SPEED_UNIT_MBPS
+ * @paramlink_text
+ * A pointer to an *rte_eth_link_text* structure to be filled with
+ * textual representation of device status
+ */
+void rte_eth_link_prepare_text(structrte_eth_link*link,uint32_tspeed_unit,lib/librte_ethdev/rte_ethdev.h +1
-1+ struct rte_eth_link_text *link_text);/** * Retrieve the general I/O statistics of an Ethernet device. * --
Quoted 2 lines
2.17.1
Considering that this function will only be used by applications that don't need to follow a vendor-specific textual format for their link status, you can choose your own text format, and don't need the struct for the text strings. The function can simply write the entire information into a single string. It also makes speed_unit superfluous. E.g. like this:
void rte_eth_link_prepare_text(char *str, const struct rte_eth_link *const link)
{
if (link.link_status == ETH_LINK_DOWN) {
str += sprintf(str, "Link down");
} else {
str += sprintf(str, "Link up at ");
if (link.link_speed == ETH_SPEED_NUM_UNKNOWN) {
str += sprintf("Unknown speed");
} else {
if (link.link_speed < ETH_SPEED_NUM_1G)
str += sprintf(str, "%u Mbit/s", link.link_speed);
else if (link.link_speed == ETH_SPEED_NUM_2_5G)
str += sprintf(str, "2.5 Gbit/s");
else
str += sprintf(str, "%u Gbit/s", link.link_speed / 1000);
str += sprintf(str, " %cDX", link.link_duplex ? 'F' : 'H');
str += sprintf(str, " %s", link.link_autoneg ? "Autoneg" : "Fixed");
}
}
}And if DPDK already has an established style for "convert information to human readable text" functions regarding function name and parameter order, the function should follow such style.
Med venlig hilsen / kind regards
- Morten Brørup
Re: [dpdk-dev] [PATCH v2 2/7] ethdev: add a link status textrepresentation
Quoted 12 lines · On Wed, 27 May 2020 09:45:49 +0200 Morten Brørup <[email protected]>…
void
rte_eth_link_prepare_text(char *str, const struct rte_eth_link *const link){ if (link.link_status == ETH_LINK_DOWN) { str += sprintf(str, "Link down"); } else { str += sprintf(str, "Link up at "); if (link.link_speed == ETH_SPEED_NUM_UNKNOWN) { str += sprintf("Unknown speed"); } else { if (link.link_speed < ETH_SPEED_NUM_1G) str += sprintf(str, "%u Mbit/s", link.link_speed); else if (link.link_speed == ETH_SPEED_NUM_2_5G)
Quoted 8 lines
str += sprintf(str, "2.5 Gbit/s");
else
str += sprintf(str, "%u Gbit/s", link.link_speed / 1000);
str += sprintf(str, " %cDX", link.link_duplex ? 'F' : 'H');
str += sprintf(str, " %s", link.link_autoneg ? "Autoneg" : "Fixed");
}
}
}Having a semi-standard link status text is good. This version of the code needs work before it is ready.
Using sprintf() rather than snprintf() is going to upset the security folks. The API must take string and length, or use asprintf();
You don't want to do last increment or Coverity will complain about useless assignment.
Re: [dpdk-dev] [PATCH v2 2/7] ethdev: add a link status textrepresentation
In reply to Morten BrørupQuoted 152 lines · Morten Brørup
Quoted 125 lines
From: dev [mailto:[email protected]] On Behalf Of Ivan Dyukov
Sent: Tuesday, May 26, 2020 9:10 PMThis commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 31 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)lib/librte_ethdev/rte_ethdev.c +14
-0@@ -2385,6 +2385,45 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)return 0 ; } +void +rte_eth_link_prepare_text (struct rte_eth_link *eth_link,uint32_t speed_unit, +struct rte_eth_link_text *link_text) +{ +uint32_t link_speed =0 ; +/* prepare link speed */ +if (eth_link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) +memcpy (link_text->link_speed,"unknown" ,sizeof ("unknown" )); +else { +if (speed_unit ==ETH_SPEED_UNIT_GBPS ) + link_speed = eth_link->link_speed /1000 ; +else + link_speed = eth_link->link_speed; + snprintf(link_text->link_speed, sizeof(link_text-Quoted 1 line
link_speed),lib/librte_ethdev/rte_ethdev.c +25
-0+ "%u", link_speed); + } +/* prepare link duplex */ +if (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) +memcpy (link_text->link_duplex,"full-duplex" , +sizeof ("full-duplex" )); +else +memcpy (link_text->link_duplex,"half-duplex" , +sizeof ("half-duplex" )); +/* prepare autoneg */ +if (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) +memcpy (link_text->link_autoneg,"autoneg" , +sizeof ("autoneg" )); +else +memcpy (link_text->link_autoneg,"fixed" , +sizeof ("fixed" )); +/* prepare status */ +if (eth_link->link_status ==ETH_LINK_DOWN ) +memcpy (link_text->link_status,"down" , +sizeof ("down" )); +else +memcpy (link_text->link_status,"up" , +sizeof ("up" )); +} +int rte_eth_stats_get (uint16_t port_id,struct rte_eth_stats *stats) {lib/librte_ethdev/rte_ethdev.h +13
-0@@ -316,6 +316,19 @@ struct rte_eth_link { uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ }__rte_aligned (8 );/**< aligned for atomic64 read/write */ +/** +* Link speed units +*/ +#define ETH_SPEED_UNIT_GBPS 0 +#define ETH_SPEED_UNIT_MBPS 1 + + +struct rte_eth_link_text { +char link_speed[14 ];/** link speed */ +char link_duplex[12 ];/** full-duplex or half-duplex */ +char link_autoneg[8 ];/** autoneg or fixed */ +char link_status[5 ];/** down or up */ +};/* Utility constants */ #define ETH_LINK_HALF_DUPLEX 0/**< Half-duplex connection (see
link_duplex). */
#defineETH_LINK_FULL_DUPLEX1 /**< Full-duplex connection (seelink_duplex). */lib/librte_ethdev/rte_ethdev.h +2
-0@@ -2295,6 +2308,24 @@ int rte_eth_link_get(uint16_t port_id, structrte_eth_link *link); */ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); +/** +* Format link status to textual representation. speed_unit is used to convert
+ *link_speedto specified unit. Also this function threats a special
+ *ETH_SPEED_NUM_UNKNOWNvalue oflink_speedand return 'UNKNOWN' speed
+ * in this case.
+ *
+ * @param link
+ * Link status provided byrte_eth_link_getfunction
+ * @paramspeed_unit
+ * Target units for the speed. Following values are available:
+ * -ETH_SPEED_UNIT_GBPS
+ * -ETH_SPEED_UNIT_MBPS
+ * @paramlink_text
+ * A pointer to an *rte_eth_link_text* structure to be filled with
+ * textual representation of device status
+ */
+void rte_eth_link_prepare_text(structrte_eth_link*link,uint32_tspeed_unit,lib/librte_ethdev/rte_ethdev.h +1
-1+ struct rte_eth_link_text *link_text);/** * Retrieve the general I/O statistics of an Ethernet device. * -- Quoted 2 lines
2.17.1
Considering that this function will only be used by applications that don't need to follow a vendor-specific textual format for their link status, you can choose your own text format, and don't need the struct for the text strings. The function can simply write the entire information into a single string. It also makes
speed_unitsuperfluous. E.g. like this:void
rte_eth_link_prepare_text(char *str, const struct rte_eth_link *const link){ if (link.link_status == ETH_LINK_DOWN) { str += sprintf(str, "Link down"); } else { str += sprintf(str, "Link up at "); if (link.link_speed == ETH_SPEED_NUM_UNKNOWN) { str += sprintf("Unknown speed"); } else { if (link.link_speed < ETH_SPEED_NUM_1G) str += sprintf(str, "%u Mbit/s", link.link_speed); else if (link.link_speed == ETH_SPEED_NUM_2_5G) str += sprintf(str, "2.5 Gbit/s"); else str += sprintf(str, "%u Gbit/s", link.link_speed / 1000); str += sprintf(str, " %cDX", link.link_duplex ? 'F' : 'H'); str += sprintf(str, " %s", link.link_autoneg ? "Autoneg" : "Fixed"); } } }
Quoted 2 lines
And if DPDK already has an established style for "convert information to human readable text" functions regarding function name and parameter order, the function should follow such style.
What about having them both, a per-formatted string that can make life easy for applications, and struct for text strings for the apps need some granularity.
Re: [dpdk-dev] [PATCH v2 2/7] ethdev: add a link status textrepresentation
Quoted 171 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Friday, June 5, 2020 1:45 PMQuoted 9 lines · Morten Brørup
Quoted 9 lines
From: dev [mailto:[email protected]] On Behalf Of Ivan Dyukov
Sent: Tuesday, May 26, 2020 9:10 PMThis commit add function which treat link status structure and format it to text representation.
Signed-off-by Ivan Dyukov <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 39++++++++++++++++++++++++++++++++++
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id,
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h | 31 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)lib/librte_ethdev/rte_ethdev.c +0
-0@@ -2385,6 +2385,45 @@ rte_eth_link_get_nowait(uint16_t port_id,struct
Quoted 82 lines
Quoted 82 lines
lib/librte_ethdev/rte_ethdev.c +14
-0rte_eth_link *eth_link)return 0 ; } +void +rte_eth_link_prepare_text (struct rte_eth_link *eth_link,uint32_t speed_unit, +struct rte_eth_link_text *link_text) +{ +uint32_t link_speed =0 ; +/* prepare link speed */ +if (eth_link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) +memcpy (link_text->link_speed,"unknown" ,sizeof ("unknown" )); +else { +if (speed_unit ==ETH_SPEED_UNIT_GBPS ) + link_speed = eth_link->link_speed /1000 ; +else + link_speed = eth_link->link_speed; + snprintf(link_text->link_speed, sizeof(link_text-Quoted 1 line
link_speed),lib/librte_ethdev/rte_ethdev.c +25
-0+ "%u", link_speed); + } +/* prepare link duplex */ +if (eth_link->link_duplex ==ETH_LINK_FULL_DUPLEX ) +memcpy (link_text->link_duplex,"full-duplex" , +sizeof ("full-duplex" )); +else +memcpy (link_text->link_duplex,"half-duplex" , +sizeof ("half-duplex" )); +/* prepare autoneg */ +if (eth_link->link_autoneg ==ETH_LINK_AUTONEG ) +memcpy (link_text->link_autoneg,"autoneg" , +sizeof ("autoneg" )); +else +memcpy (link_text->link_autoneg,"fixed" , +sizeof ("fixed" )); +/* prepare status */ +if (eth_link->link_status ==ETH_LINK_DOWN ) +memcpy (link_text->link_status,"down" , +sizeof ("down" )); +else +memcpy (link_text->link_status,"up" , +sizeof ("up" )); +} +int rte_eth_stats_get (uint16_t port_id,struct rte_eth_stats *stats) {lib/librte_ethdev/rte_ethdev.h +13
-0@@ -316,6 +316,19 @@ struct rte_eth_link { uint16_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ }__rte_aligned (8 );/**< aligned for atomic64 read/write */ +/** +* Link speed units +*/ +#define ETH_SPEED_UNIT_GBPS 0 +#define ETH_SPEED_UNIT_MBPS 1 + + +struct rte_eth_link_text { +char link_speed[14 ];/** link speed */ +char link_duplex[12 ];/** full-duplex or half-duplex */ +char link_autoneg[8 ];/** autoneg or fixed */ +char link_status[5 ];/** down or up */ +};/* Utility constants */ #define ETH_LINK_HALF_DUPLEX 0/**< Half-duplex connection (see
link_duplex). */
#defineETH_LINK_FULL_DUPLEX1 /**< Full-duplex connection (seelink_duplex). */lib/librte_ethdev/rte_ethdev.h +0
-0@@ -2295,6 +2308,24 @@ int rte_eth_link_get(uint16_t port_id, structrte_eth_link *link); */ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link);Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct · line 2314
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2
-0+/** +* Format link status to textual representation. speed_unit is used to
Quoted 2 lines
Quoted 2 lines
convert
+ *link_speedto specified unit. Also this function threats aspecial
Quoted 4 lines
Quoted 4 lines
+ *
ETH_SPEED_NUM_UNKNOWNvalue oflink_speedand return 'UNKNOWN' speed
+ * in this case.
+ *Quoted 8 lines
Quoted 8 lines
+ * @param link
+ * Link status provided byrte_eth_link_getfunction
+ * @paramspeed_unit
+ * Target units for the speed. Following values are available:
+ * -ETH_SPEED_UNIT_GBPS
+ * -ETH_SPEED_UNIT_MBPS
+ * @paramlink_text
+ * A pointer to an *rte_eth_link_text* structure to be filledwith
Quoted 5 lines
Quoted 5 lines
+ * textual representation of device status
+ */
+void rte_eth_link_prepare_text(structrte_eth_link*link,uint32_tspeed_unit,lib/librte_ethdev/rte_ethdev.h +1
-0+ struct rte_eth_link_text *link_text);Quoted 8 lines
Quoted 6 lines
/**
* Retrieve the general I/O statistics of an Ethernet device. *
--
2.17.1Considering that this function will only be used by applications that
don't need to follow a vendor-specific textual format for their link status, you can choose your own text format, and don't need the struct for the text strings. The function can simply write the entire information into a single string. It also makes
speed_unitsuperfluous. E.g. like this:Quoted 2 lines
void rte_eth_link_prepare_text(char *str, const struct
rte_eth_link*const link)
Quoted 6 lines
{ if (link.link_status == ETH_LINK_DOWN) { str += sprintf(str, "Link down"); } else { str += sprintf(str, "Link up at "); if (link.link_speed == ETH_SPEED_NUM_UNKNOWN) {Quoted 8 lines
str += sprintf("Unknown speed"); } else { if (link.link_speed < ETH_SPEED_NUM_1G) str += sprintf(str, "%u Mbit/s", link.link_speed); else if (link.link_speed == ETH_SPEED_NUM_2_5G) str += sprintf(str, "2.5 Gbit/s"); else str += sprintf(str, "%u Gbit/s", link.link_speed /1000);
Quoted 1 line
str += sprintf(str, " %cDX", link.link_duplex ? 'F' :'H');
Quoted 1 line
str += sprintf(str, " %s", link.link_autoneg ? "Autoneg": "Fixed");
Quoted 6 lines
} } }And if DPDK already has an established style for "convert information
Quoted 9 lines
to human readable text" functions regarding function name and parameter order, the function should follow such style.
Quoted 1 line
What about having them both, a per-formatted string that can make life easy for
applications, and struct for text strings for the apps need some granularity.
Not necessary. Application developers can easily write their own link status formatting functions.
And the formatting function provided by DPDK can be used as a reference if the application developer needs more detailed information. That is one of the beauties of Open Source Software - the source code supplements the documentation.
PATCH v2 3/7 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_prepare_text function to example applications
--- app/proc-info/main.c | 15 +++++++++------ app/test-pipeline/init.c | 11 ++++++----- app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 10 ++++++---- app/test/test_pmd_perf.c | 10 ++++++---- 5 files changed, 39 insertions(+), 27 deletions(-)
app/proc-info/main.c +9 -6
@@ -669,6 +669,7 @@ show_port(void)RTE_ETH_FOREACH_DEV (i) {uint16_t mtu =0 ;struct rte_eth_link link; +struct rte_eth_link_text link_text;struct rte_eth_dev_info dev_info;struct rte_eth_rxq_info queue_info;struct rte_eth_rss_conf rss_conf;
@@ -685,12 +686,14 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_prepare_text (&link, +ETH_SPEED_UNIT_MBPS , &link_text); +printf ("\t -- link speed: %s, duplex: %s," +" auto neg: %s, status: %s\n" , + link_text.link_speed, + link_text.link_duplex, + link_text.link_autoneg, + link_text.link_status); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +6 -5
@@ -160,6 +160,7 @@ app_ports_check_link(void)for (i =0 ; i < app.n_ports; i++) {struct rte_eth_link link; +struct rte_eth_link_text link_text;uint16_t port;int ret;
@@ -173,12 +174,12 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_prepare_text (&link, +ETH_SPEED_UNIT_GBPS , &link_text); +RTE_LOG (INFO ,USER1 ,"Port %u (%s Gbps) %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_text.link_speed, + link_text.link_status);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +12 -8
@@ -552,6 +552,7 @@ port_infos_display(portid_t port_id)struct rte_port *port;struct rte_ether_addr mac_addr;struct rte_eth_link link; +struct rte_eth_link_text link_text;struct rte_eth_dev_info dev_info;int vlan_offload;struct rte_mempool * mp;
@@ -600,10 +601,10 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_prepare_text (&link,ETH_SPEED_UNIT_MBPS , &link_text); +printf ("\nLink status: %s\n" , link_text.link_status); +printf ("Link speed: %s Mbps\n" , link_text.link_speed); +printf ("Link duplex: %s\n" , link_text.link_duplex);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -724,6 +725,7 @@ port_summary_display(portid_t port_id) {struct rte_ether_addr mac_addr;struct rte_eth_link link; +struct rte_eth_link_text link_text;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ];int ret;
@@ -746,12 +748,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_prepare_text (&link,ETH_SPEED_UNIT_GBPS , + &link_text); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, link_text.link_status, + link_text.link_speed); }void
@@ -3897,7 +3901,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=UINT32_MAX && rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +6 -4
@@ -2987,6 +2987,7 @@ check_all_ports_link_status(uint32_t port_mask)portid_t portid;uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link; +struct rte_eth_link_text link_text;int ret;printf ("Checking link statuses...\n" );
@@ -3007,12 +3008,13 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { +rte_eth_link_prepare_text (&link, +ETH_SPEED_UNIT_MBPS , &link_text);if (link.link_status)printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +"Port%d Link Up. speed %s Mbps- %s\n" , + portid, link_text.link_speed, + link_text.link_duplex);else printf ("Port %d Link Down\n" , portid);continue ;
app/test/test_pmd_perf.c +6 -4
@@ -125,6 +125,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link; +struct rte_eth_link_text link_text;int ret;printf ("Checking link statuses...\n" );
@@ -147,11 +148,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)/* print link status if flag set */ if (print_flag ==1 ) {if (link.link_status) { +rte_eth_link_prepare_text (&link, +ETH_SPEED_UNIT_MBPS , &link_text);printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +"Port%d Link Up. Speed %s Mbps - %s\n" , + portid, link_text.link_speed, + link_text.link_duplex);if (link_mbps ==0 ) link_mbps = link.link_speed; }else
Signature · 1 line
2.17.1
PATCH v2 4/7 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_prepare_text function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +4 -2
@@ -157,6 +157,7 @@ An example callback function that has been written as indicated below. lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param) { struct rte_eth_link link; + struct rte_eth_link_text link_text; int ret; RTE_SET_USED(param);
@@ -170,8 +171,9 @@ An example callback function that has been written as indicated below. printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); + rte_eth_link_prepare_text(&link), ETH_SPEED_UNIT_MBPS, &link_text); + printf("Port %d Link Up - speed %s Mbps - %s\n\n", port_id, link_text.link_speed, + link_text.link_duplex); } else printf("Port %d Link Down\n\n", port_id); }
Signature · 1 line
2.17.1
PATCH v2 5/7 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v2 6/7 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2889,7 +2889,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2165,15 +2165,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v2 7/7 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3112,8 +3112,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
v3 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 9 +- app/test-pipeline/init.c | 10 +- app/test-pmd/config.c | 19 +-- app/test-pmd/testpmd.c | 9 +- app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 253 +++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +-- doc/guides/sample_app_ug/link_status_intr.rst | 10 +- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 +- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +- lib/librte_ethdev/rte_ethdev.c | 163 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 72 +++++++++-- 16 files changed, 529 insertions(+), 65 deletions(-)
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v3 1/7 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 1/7] ethdev: allow unknown link speed
Quoted 16 lines · Ivan Dyukov
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)This API update is making explicit that the link speed information is optional.
The valueETH_SPEED_NUM_NONE(0) was already part of the API. The valueETH_SPEED_NUM_UNKNOWN(infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
Quoted 3 lines
Suggested-by Morten Brørup <[email protected]>Suggested-by Benoit Ganne <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
PATCH v3 2/7 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 253 +++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 163 +++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 52 +++++++ 6 files changed, 474 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -378,6 +378,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -249,6 +249,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -38,6 +38,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -196,6 +197,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status' true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +253 -0
253 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +163 -0
169 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +52 -0
58 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status text representation
Quoted 2 lines · Ivan Dyukov
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from speed checks everytime loging link information caused by this new 'unknown' speed.
And later suggestion was to have a pre-formatted text for link logging.
This patch brings additional link status printing/formatting capability with custom format string support and with new format specifiers for link (like, '%D' link duplex state),
although this is nice work and thanks for it, I am not sure this complexity and two new APIs are really needed.
For me only 'rte_eth_link_format()' without custom format support looks good enough but I won't object if the concensus is to have them.
I am aware there are multiple applications you are updating logging slightly different which requires this flexibility but what happens if they use same pre-formatted text, is that difference really required or happened by time based on developers taste?
I will put some comments below in any case.
Quoted 2 lines
Signed-off-by Ivan Dyukov <[email protected]>
<...>
app/test/Makefile SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c · line 253
Quoted 6 lines
app/test/Makefile +2
-0@@ -249,6 +249,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c
+1 to unit test.
<...>
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2394
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7
-0+int +rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + ret =rte_eth_link_format (text,200 , fmt, link);
Will it be paranoid to add "text[199] = 0" to be sure any custom 'fmt' won't cause any harm?
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2395
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+printf ("%s" , text);
Not sure if the error still should be printed on error case? Like for example what the code does when fmt="%X"?
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2401
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+return ret; +} + +int +rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *link)
Why not have the 'len' type 'size_t'?
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.c +24
-0+int offset =0 ; +int32_t clen = len; +const char *fmt_cur = fmt; +double gbits = (double )link->link_speed /1000. ; +/* TBD: make it international? */ +static const char LINK_DOWN_STR [] ="Link down" ; +static const char LINK_UP_STR [] ="Link up at " ; +static const char UNKNOWN_SPEED_STR [] ="Unknown speed" ; +static const char MBITS_STR [] ="Mbit/s" ; +static const char GBITS_STR [] ="Gbit/s" ; +static const char AUTONEG_STR [] ="Autoneg" ; +static const char FIXED_STR [] ="Fixed" ; +static const char FDX_STR [] ="FDX" ; +static const char HDX_STR [] ="HDX" ; +static const char UNKNOWN_STR [] ="Unknown" ; +static const char UP_STR [] ="Up" ; +static const char DOWN_STR [] ="Down" ; +if (str ==NULL || len ==0 ) +return -1 ; +/* default format string, if no fmt is specified */ +if (fmt ==NULL ) { +if (link->link_status ==ETH_LINK_DOWN ) +return snprintf (str, (size_t )clen,"%s" ,LINK_DOWN_STR ); +
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2436
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ offset =snprintf (str, (size_t )clen,"%s" ,LINK_UP_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ; + clen -= offset; + str += offset; +if (link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) { + offset =snprintf (str, clen,"%s" , +UNKNOWN_SPEED_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ;
better to use 'strlcpy' & 'strlcat', they are easier to use for these kind of checks.
<...>
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+/* Formated status */ + }else { +char c = *fmt_cur; +while (c) { +if (clen <=0 ) +return -1 ; +if (c =='%' ) { + c = *++fmt_cur; +switch (c) { +/* Speed in Mbits/s */
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2492
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =snprintf (str, + clen,"%s" , +UNKNOWN_STR ); +else + offset =snprintf (str, + clen,"%u" , + link->link_speed);
Code readiblity is not great here because you hit the 80char limit, this is a sign that something is wrong like function is already too long.
Can you please try to fix this, like extracting some part of the code to its own function or return after end of the 'if' statement which can save one more level indentation etc...
<...>
Quoted 17 lines
lib/librte_ethdev/rte_ethdev.h +9
-0@@ -2295,6 +2295,58 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); + +/** +* print formated link status to stdout. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied.
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2316
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s +* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state +* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to stdout. In case of error, -1 is returned.
Does it worth to mention the log still will be printed on error?
Quoted 23 lines
lib/librte_ethdev/rte_ethdev.h +23
-0+* +*/ +int rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link); + +/** +* Format link status to textual representation. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param str +* A pointer to a string to be filled with textual representation of +* device status. +* @param len +* Length of available memory at 'str' string. +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s +* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2349
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to str array. In case of error, -1 is returned. +* +*/ +int rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *eth_link); +
These new APIs needs to be experimental by process (__rte_experimental).
Need the add these APIs to the .map file (rte_ethdev_version.map), so that they will be exported in the dynamic library (.so).
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status text representation
Hi Ferruh,
Thank you for the comments.
My answers are inlined.
Best regards,
Ivan
17.06.2020 19:45, Ferruh Yigit пишет:
Quoted 7 lines · Ivan Dyukov
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from speed checks everytime loging link information caused by this new 'unknown' speed.
And later suggestion was to have a pre-formatted text for link logging.
Correct.
Quoted 6 lines
This patch brings additional link status printing/formatting capability with custom format string support and with new format specifiers for link (like, '%D' link duplex state),
although this is nice work and thanks for it, I am not sure this complexity and two new APIs are really needed.
Yep.
Quoted 6 lines
For me only '
rte_eth_link_format()' without custom format support looks good enough but I won't object if the concensus is to have them.
I am aware there are multiple applications you are updating logging slightly different which requires this flexibility but what happens if they use same pre-formatted text, is that difference really required or happened by time based on developers taste?
I have changed only few applications but I have plan to change all dpdk examples. Even in those few apps, we have various link status logging text. e.g app/test-pmd/config.c
@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id)
} else
printf("\nmemory allocation on the socket:
%u",port->socket_id);
- printf("\nLink status: %s\n", (link.link_status) ? ("up") :
("down"));
- printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
+ rte_eth_link_printf("\nLink status: %S\n"
+ "Link speed: %M Mbps\n"
+ "Link duplex: %D\n", &link);
the status is logged in 3 lines. this is special text layoting and I don't know how it will look in one line. Myabe it will require reformat all screen. I don't want to change screen layoting in this patchset.
Quoted 15 lines
I will put some comments below in any case.
Quoted 1 line
Signed-off-by Ivan Dyukov <[email protected]><...>
app/test/Makefile SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c · line 253
Quoted 6 lines
app/test/Makefile +2
-0@@ -249,6 +249,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c+1 to unit test.
<...>
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2394
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7
-0+int +rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + ret =rte_eth_link_format (text,200 , fmt, link);Will it be paranoid to add "text[199] = 0" to be sure any custom 'fmt' won't cause any harm?
rte_eth_link_format already do that and it must do that. I would prefer to don't hide rte_eth_link_format bugs in rte_eth_link_printf function.
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2395
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+printf ("%s" , text);Not sure if the error still should be printed on error case? Like for example what the code does when fmt="%X"?
yep. I'll add 'ret' check.
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2401
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+return ret; +} + +int +rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *link)Why not have the 'len' type '
size_t'?
Yes, I can change type of the len but internally we have 'int32_t clen = len;'
defined below. clen should be signed variable because rte_eth_link_format
much more simpler then snprintf. e.g. snprintf may be called with
snprintf(buff, 0, "some text %d", val); no errors returned in this case.
it returns length of formated string.so internally I use signed clen
to detect end of line and avoid uint overflow.
rte_eth_link_format with incorrect or short buffer returns error.
Quoted 29 lines
Quoted 29 lines
lib/librte_ethdev/rte_ethdev.c +28
-0+int offset =0 ; +int32_t clen = len; +const char *fmt_cur = fmt; +double gbits = (double )link->link_speed /1000. ; +/* TBD: make it international? */ +static const char LINK_DOWN_STR [] ="Link down" ; +static const char LINK_UP_STR [] ="Link up at " ; +static const char UNKNOWN_SPEED_STR [] ="Unknown speed" ; +static const char MBITS_STR [] ="Mbit/s" ; +static const char GBITS_STR [] ="Gbit/s" ; +static const char AUTONEG_STR [] ="Autoneg" ; +static const char FIXED_STR [] ="Fixed" ; +static const char FDX_STR [] ="FDX" ; +static const char HDX_STR [] ="HDX" ; +static const char UNKNOWN_STR [] ="Unknown" ; +static const char UP_STR [] ="Up" ; +static const char DOWN_STR [] ="Down" ; +if (str ==NULL || len ==0 ) +return -1 ; +/* default format string, if no fmt is specified */ +if (fmt ==NULL ) { +if (link->link_status ==ETH_LINK_DOWN ) +return snprintf (str, (size_t )clen,"%s" ,LINK_DOWN_STR ); + + offset =snprintf (str, (size_t )clen,"%s" ,LINK_UP_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ; + clen -= offset;
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2436
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+ str += offset; +if (link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) { + offset =snprintf (str, clen,"%s" , +UNKNOWN_SPEED_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ;better to use 'strlcpy' & 'strlcat', they are easier to use for these kind of checks.
OK
Quoted 20 lines
<...>
Quoted 17 lines
lib/librte_ethdev/rte_ethdev.c +17
-0+/* Formated status */ + }else { +char c = *fmt_cur; +while (c) { +if (clen <=0 ) +return -1 ; +if (c =='%' ) { + c = *++fmt_cur; +switch (c) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =snprintf (str, + clen,"%s" , +UNKNOWN_STR ); +else
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2492
Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ offset =snprintf (str, + clen,"%u" , + link->link_speed);Code readiblity is not great here because you hit the 80char limit, this is a sign that something is wrong like function is already too long.
Can you please try to fix this, like extracting some part of the code to its own function or return after end of the 'if' statement which can save one more level indentation etc...
agree. I'll define one static function and move part of the code to it. It should reduce indent.
Quoted 23 lines
<...>
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.h +12
-0@@ -2295,6 +2295,58 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); + +/** +* print formated link status to stdout. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2316
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h +7
-0+* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state +* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to stdout. In case of error, -1 is returned. Does it worth to mention the log still will be printed on error?
I'll change the function. It will print nothing on error.
Quoted 40 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.h +23
-0+* +*/ +int rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link); + +/** +* Format link status to textual representation. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param str +* A pointer to a string to be filled with textual representation of +* device status. +* @param len +* Length of available memory at 'str' string. +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s +* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2349
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to str array. In case of error, -1 is returned. +* +*/ +int rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *eth_link); +These new APIs needs to be experimental by process (
__rte_experimental).Need the add these APIs to the .map file (rte_ethdev_version.map), so that they will be exported in the dynamic library (.so).
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status text representation
Quoted 42 lines · Ivan Dyukov
Hi Ferruh,
Thank you for the comments.
My answers are inlined.
Best regards,
Ivan
17.06.2020 19:45, Ferruh Yigit пишет:Quoted 7 lines · Ivan Dyukov
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from speed checks everytime loging link information caused by this new 'unknown' speed.
And later suggestion was to have a pre-formatted text for link logging.
Correct.
Quoted 6 lines
This patch brings additional link status printing/formatting capability with custom format string support and with new format specifiers for link (like, '%D' link duplex state),
although this is nice work and thanks for it, I am not sure this complexity and two new APIs are really needed.Yep.
Quoted 6 lines
For me only '
rte_eth_link_format()' without custom format support looks good enough but I won't object if the concensus is to have them.
I am aware there are multiple applications you are updating logging slightly different which requires this flexibility but what happens if they use same pre-formatted text, is that difference really required or happened by time based on developers taste?I have changed only few applications but I have plan to change all dpdk examples. Even in those few apps, we have various link status logging text. e.g
app/test-pmd/config.c(quoted diff) +0
-3@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex ==
Quoted 8 lines
ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
+ rte_eth_link_printf("\nLink status: %S\n"
+ "Link speed: %M Mbps\n"
+ "Link duplex: %D\n", &link);
the status is logged in 3 lines. this is special text layoting and I don't know how it will look in one line. Myabe it will require reformat all screen. I don't want to change screen layoting in this patchset.
cc'ed Morten & Stephen.
To keep existing layout in the applications yes you need more flexibility, a pre-formatted text won't cut it, but I guess I prefer your approach in v2 for simplicity.
And I would prefer extending the one in v2 with a larger string for the pre-formatted text, so both flexibility and the standard output can be provided, Morten didn't like it but if I understand correctly his comment was to keep more simple solution in ethdev and applications can do it themselves if they want more custom log formatting, but this patch adds more complex and flexible logging support to the ethdev.
Quoted 26 lines
Quoted 16 lines
I will put some comments below in any case.
Quoted 1 line
Signed-off-by Ivan Dyukov <[email protected]><...>
app/test/Makefile SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c · line 253
Quoted 6 lines
app/test/Makefile +2
-0@@ -249,6 +249,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c+1 to unit test.
<...>
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2394
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7
-0+int +rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + ret =rte_eth_link_format (text,200 , fmt, link);Will it be paranoid to add "text[199] = 0" to be sure any custom 'fmt' won't cause any harm?
Quoted 1 line
rte_eth_link_formatalready do that and it must do that. I would prefer to don't hiderte_eth_link_formatbugs inrte_eth_link_printffunction.
OK, makes sense.
What do you think putting an assert (RTE_ASSERT) to check that formatted buffer is proper C string?
Quoted 15 lines
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2395
Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+printf ("%s" , text);Not sure if the error still should be printed on error case? Like for example what the code does when fmt="%X"?
yep. I'll add 'ret' check.
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2401
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+return ret; +} + +int +rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *link)Why not have the 'len' type '
size_t'?
Quoted 8 lines
Yes, I can change type of the len but internally we have '
int32_tclen = len;'
defined below. clen should be signed variable becauserte_eth_link_formatmuch more simpler then snprintf. e.g. snprintf may be called withsnprintf(buff, 0, "some text %d", val); no errors returned in this case. it returns length of formated string.so internally I use signed clen to detect end of line and avoid uint overflow.rte_eth_link_formatwith incorrect or short buffer returns error.
I see, using 'strlcat' and 'strlcpy' may help here, since both does get full size of the buffer as parameter which removes the need of offset calculations and possible negative values there. And both returns positive values, again prevents using signed variables to capture return value.
So I think this can make possible to only use size_t variable as length.
Quoted 142 lines
Quoted 30 lines
Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +28
-0+int offset =0 ; +int32_t clen = len; +const char *fmt_cur = fmt; +double gbits = (double )link->link_speed /1000. ; +/* TBD: make it international? */ +static const char LINK_DOWN_STR [] ="Link down" ; +static const char LINK_UP_STR [] ="Link up at " ; +static const char UNKNOWN_SPEED_STR [] ="Unknown speed" ; +static const char MBITS_STR [] ="Mbit/s" ; +static const char GBITS_STR [] ="Gbit/s" ; +static const char AUTONEG_STR [] ="Autoneg" ; +static const char FIXED_STR [] ="Fixed" ; +static const char FDX_STR [] ="FDX" ; +static const char HDX_STR [] ="HDX" ; +static const char UNKNOWN_STR [] ="Unknown" ; +static const char UP_STR [] ="Up" ; +static const char DOWN_STR [] ="Down" ; +if (str ==NULL || len ==0 ) +return -1 ; +/* default format string, if no fmt is specified */ +if (fmt ==NULL ) { +if (link->link_status ==ETH_LINK_DOWN ) +return snprintf (str, (size_t )clen,"%s" ,LINK_DOWN_STR ); + + offset =snprintf (str, (size_t )clen,"%s" ,LINK_UP_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ; + clen -= offset;Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2436
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+ str += offset; +if (link->link_speed ==ETH_SPEED_NUM_UNKNOWN ) { + offset =snprintf (str, clen,"%s" , +UNKNOWN_SPEED_STR ); +if (offset <0 || (clen - offset) <=0 ) +return -1 ;better to use 'strlcpy' & 'strlcat', they are easier to use for these kind of checks.
OK
Quoted 20 lines
<...>
Quoted 17 lines
lib/librte_ethdev/rte_ethdev.c +17
-0+/* Formated status */ + }else { +char c = *fmt_cur; +while (c) { +if (clen <=0 ) +return -1 ; +if (c =='%' ) { + c = *++fmt_cur; +switch (c) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =snprintf (str, + clen,"%s" , +UNKNOWN_STR ); +else Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2492
Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ offset =snprintf (str, + clen,"%u" , + link->link_speed);Code readiblity is not great here because you hit the 80char limit, this is a sign that something is wrong like function is already too long.
Can you please try to fix this, like extracting some part of the code to its own function or return after end of the 'if' statement which can save one more level indentation etc...agree. I'll define one static function and move part of the code to it. It should reduce indent.
Quoted 23 lines
<...>
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.h +12
-0@@ -2295,6 +2295,58 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);*/ int rte_eth_link_get_nowait (uint16_t port_id,struct rte_eth_link *link); + +/** +* print formated link status to stdout. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2316
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h +7
-0+* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state +* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to stdout. In case of error, -1 is returned. Does it worth to mention the log still will be printed on error?
I'll change the function. It will print nothing on error.
Quoted 40 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.h +23
-0+* +*/ +int rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link); + +/** +* Format link status to textual representation. This function threats all +* special values like ETH_SPEED_NUM_UNKNOWN, ETH_LINK_DOWN etc. and convert +* them to textual representation. +* +* @param str +* A pointer to a string to be filled with textual representation of +* device status. +* @param len +* Length of available memory at 'str' string. +* @param fmt +* Format string which allow to format link status. If NULL is provided +* , default formating will be applied. +* Following specifiers are available: +* - '%M' link speed in Mbits/s +* - '%G' link speed in Gbits/s +* - '%S' link status. e.g. Up or Down +* - '%A' link autonegotiation state lib/librte_ethdev/rte_ethdev.h int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); · line 2349
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* - '%D' link duplex state +* @param link +* Link status provided by rte_eth_link_get function +* @return +* - Number of bytes written to str array. In case of error, -1 is returned. +* +*/ +int rte_eth_link_format (char *str,int32_t len,const char *const fmt, +struct rte_eth_link *eth_link); +These new APIs needs to be experimental by process (
__rte_experimental).Need the add these APIs to the .map file (rte_ethdev_version.map), so that they will be exported in the dynamic library (.so).
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status textrepresentation
Quoted 75 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Thursday, June 18, 2020 2:03 PMQuoted 13 lines · Ivan Dyukov
Hi Ferruh,
Thank you for the comments.
My answers are inlined.
Best regards,
Ivan
17.06.2020 19:45, Ferruh Yigit пишет:Quoted 4 lines · Ivan Dyukov
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from
speed checks
Quoted 1 line
Quoted 1 line
everytime loging link information caused by this new 'unknown'
speed.
Quoted 2 lines
Quoted 2 lines
And later suggestion was to have a pre-formatted text for link
logging.
Quoted 3 lines
Correct.
Quoted 2 lines
This patch brings additional link status printing/formatting
capability with
Quoted 1 line
Quoted 1 line
custom format string support and with new format specifiers for link
(like, '%D'
Quoted 2 lines
Quoted 2 lines
link duplex state),
although this is nice work and thanks for it, I am not sure thiscomplexity and
Quoted 3 lines
Quoted 1 line
two new APIs are really needed.
Yep.
Quoted 1 line
For me only '
rte_eth_link_format()' without custom format supportlooks good
Quoted 2 lines
Quoted 2 lines
enough but I won't object if the concensus is to have them. I am aware there are multiple applications you are updating logging
slightly
Quoted 1 line
Quoted 1 line
different which requires this flexibility but what happens if they
use same
Quoted 1 line
Quoted 1 line
pre-formatted text, is that difference really required or happened
by time based
Quoted 2 lines
Quoted 1 line
on developers taste?
I have changed only few applications but I have plan to change all
dpdk
Quoted 11 lines
examples. Even in those few apps, we have various link status logging text. e.g
app/test-pmd/config.c(quoted diff) +0
-3@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex ==Quoted 7 lines
ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
+ rte_eth_link_printf("\nLink status: %S\n"
+ "Link speed: %M Mbps\n"
+ "Link duplex: %D\n", &link); the status is logged in 3 lines. this is special text layoting and I don't know how it will look in one line. Myabe it will requirereformat
Quoted 1 line
all screen. I don't want to change screen layoting in this patchset.
cc'ed Morten & Stephen.
To keep existing layout in the applications yes you need more flexibility, a
pre-formatted text won't cut it, but I guess I prefer your approach in v2 for
simplicity.
Quoted 11 lines
And I would prefer extending the one in v2 with a larger string for the pre-formatted text, so both flexibility and the standard output can be provided,
Morten didn't like it but if I understand correctly his comment was to keep more
simple solution in ethdev and applications can do it themselves if they want
more custom log formatting, but this patch adds more complex and flexible
logging support to the ethdev.
If you are going to add a flexible link status formatting function, like strftime(), it should not print to stdout, but to a string buffer, like strftime(). It will also allow for new format specifiers in the future, e.g. %1D for "FDX"/"HDX", %2D for "Full"/"Half" or %3D for "full-duplex"/"half-duplex". This would provide more flexible support for a larger number of application specific formats.
Then the function for printing to stdout in a DPDK preferred format (if you add such a function to the library) can use the above eth_link_strf() function.
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status textrepresentation
Quoted 87 lines · Morten Brørup
Quoted 75 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Thursday, June 18, 2020 2:03 PMQuoted 13 lines · Ivan Dyukov
Hi Ferruh,
Thank you for the comments.
My answers are inlined.
Best regards,
Ivan
17.06.2020 19:45, Ferruh Yigit пишет:Quoted 4 lines · Ivan Dyukov
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from
speed checks
Quoted 1 line
Quoted 1 line
everytime loging link information caused by this new 'unknown'
speed.
Quoted 2 lines
Quoted 2 lines
And later suggestion was to have a pre-formatted text for link
logging.
Quoted 3 lines
Correct.
Quoted 2 lines
This patch brings additional link status printing/formatting
capability with
Quoted 1 line
Quoted 1 line
custom format string support and with new format specifiers for link
(like, '%D'
Quoted 2 lines
Quoted 2 lines
link duplex state),
although this is nice work and thanks for it, I am not sure thiscomplexity and
Quoted 3 lines
Quoted 1 line
two new APIs are really needed.
Yep.
Quoted 1 line
For me only '
rte_eth_link_format()' without custom format supportlooks good
Quoted 2 lines
Quoted 2 lines
enough but I won't object if the concensus is to have them. I am aware there are multiple applications you are updating logging
slightly
Quoted 1 line
Quoted 1 line
different which requires this flexibility but what happens if they
use same
Quoted 1 line
Quoted 1 line
pre-formatted text, is that difference really required or happened
by time based
Quoted 2 lines
Quoted 1 line
on developers taste?
I have changed only few applications but I have plan to change all
dpdk
Quoted 11 lines
examples. Even in those few apps, we have various link status logging text. e.g
app/test-pmd/config.c(quoted diff) +0
-3@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex ==Quoted 7 lines
ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
+ rte_eth_link_printf("\nLink status: %S\n"
+ "Link speed: %M Mbps\n"
+ "Link duplex: %D\n", &link); the status is logged in 3 lines. this is special text layoting and I don't know how it will look in one line. Myabe it will requirereformat
Quoted 1 line
all screen. I don't want to change screen layoting in this patchset.
cc'ed Morten & Stephen.
To keep existing layout in the applications yes you need more flexibility, a
pre-formatted text won't cut it, but I guess I prefer your approach in v2 for
simplicity.Quoted 11 lines
And I would prefer extending the one in v2 with a larger string for the pre-formatted text, so both flexibility and the standard output can be provided,
Morten didn't like it but if I understand correctly his comment was to keep more
simple solution in ethdev and applications can do it themselves if they want
more custom log formatting, but this patch adds more complex and flexible
logging support to the ethdev.
Quoted 1 line
If you are going to add a flexible link status formatting function, like
strftime(), it should not print to stdout, but to a string buffer, likestrftime(). It will also allow for new format specifiers in the future, e.g. %1D for "FDX"/"HDX", %2D for "Full"/"Half" or %3D for "full-duplex"/"half-duplex". This would provide more flexible support for a larger number of application specific formats.
These will make it even more complex, do we really need this?
Quoted 4 lines
Then the function for printing to stdout in a DPDK preferred format (if you add such a function to the library) can use the above
eth_link_strf()function.
Re: [dpdk-dev] [PATCH v3 2/7] ethdev: add a link status textrepresentation
Quoted 102 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Monday, June 22, 2020 9:05 AMQuoted 21 lines · Morten Brørup
Quoted 21 lines
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Thursday, June 18, 2020 2:03 PMQuoted 13 lines · Ivan Dyukov
Hi Ferruh,
Thank you for the comments.
My answers are inlined.
Best regards,
Ivan
17.06.2020 19:45, Ferruh Yigit пишет:Quoted 4 lines · Ivan Dyukov
Quoted 2 lines
This commit add function which treat link status structure and format it to text representation.
If I am following correctly, the initial need was to escape from
speed checks
Quoted 1 line
Quoted 1 line
everytime loging link information caused by this new 'unknown'
speed.
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
And later suggestion was to have a pre-formatted text for link
logging.
Quoted 3 lines
Correct.
Quoted 2 lines
This patch brings additional link status printing/formatting
capability with
Quoted 1 line
Quoted 1 line
custom format string support and with new format specifiers for
link
Quoted 10 lines
Quoted 10 lines
(like, '%D'
Quoted 2 lines
Quoted 2 lines
link duplex state),
although this is nice work and thanks for it, I am not sure thiscomplexity and
Quoted 3 lines
Quoted 1 line
two new APIs are really needed.
Yep.
Quoted 1 line
For me only '
rte_eth_link_format()' without custom format supportlooks good
Quoted 2 lines
Quoted 2 lines
enough but I won't object if the concensus is to have them. I am aware there are multiple applications you are updating
logging
Quoted 9 lines
Quoted 9 lines
slightly
Quoted 1 line
Quoted 1 line
different which requires this flexibility but what happens if they
use same
Quoted 1 line
Quoted 1 line
pre-formatted text, is that difference really required or happened
by time based
Quoted 2 lines
Quoted 1 line
on developers taste?
I have changed only few applications but I have plan to change all
dpdk
Quoted 1 line
examples. Even in those few apps, we have various link status
logging
Quoted 9 lines
Quoted 9 lines
Review port_infos_display(portid_t port_id) · line 606
Quoted 9 lines
text. e.g
app/test-pmd/config.c(quoted diff) +0
-2@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned)link.link_speed);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0
-1- printf("Link duplex: %s\n", (link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
+ rte_eth_link_printf("\nLink status: %S\n"
+ "Link speed: %M Mbps\n"
+ "Link duplex: %D\n", &link); the status is logged in 3 lines. this is special text layoting andI
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
don't know how it will look in one line. Myabe it will require
reformat
Quoted 1 line
all screen. I don't want to change screen layoting in this
patchset.
Quoted 6 lines
Quoted 6 lines
cc'ed Morten & Stephen.
To keep existing layout in the applications yes you need more flexibility, a
pre-formatted text won't cut it, but I guess I prefer your approachin
Quoted 4 lines
Quoted 4 lines
v2 for
simplicity.And I would prefer extending the one in v2 with a larger string for
the
Quoted 1 line
Quoted 1 line
pre-formatted text, so both flexibility and the standard output can
be
Quoted 2 lines
Quoted 2 lines
provided,
Morten didn't like it but if I understand correctly his comment wasto
Quoted 2 lines
Quoted 2 lines
keep more
simple solution in ethdev and applications can do it themselves ifthey
Quoted 6 lines
Quoted 5 lines
want
more custom log formatting, but this patch adds more complex and flexible
logging support to the ethdev.
Quoted 8 lines
Quoted 1 line
If you are going to add a flexible link status formatting function,
like
strftime(), it should not print to stdout, but to a string buffer, likestrftime(). It will also allow for new format specifiers in the future, e.g. %1D for "FDX"/"HDX", %2D for "Full"/"Half" or %3D for "full-duplex"/"half-duplex". This would provide more flexible support for a larger number of application specific formats.These will make it even more complex, do we really need this?
It only needs to support the format specifiers required for the preferred DPDK text format, initially. It can be extended at a later time with more format specifiers.
And the implementation could be somewhat simplified by specifying that the length of the provided string buffer should be large enough to hold the result, or only a partial (or possibly empty) string will be returned.
I prefer a flexible formatting function over the initially suggested function that takes a struct of string buffers with only one way of formatting the strings. Or, we can leave it up to the application to do the text formatting.
Quoted 5 lines
Quoted 3 lines
Then the function for printing to stdout in a DPDK preferred format
(if you add such a function to the library) can use the above
eth_link_strf()function.
PATCH v3 3/7 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_format function to example applications
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 10 ++++------ app/test-pmd/config.c | 19 +++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 26 insertions(+), 38 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +4 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,10 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_format (status_text,50 ,"(%G Gbps) %S" , &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +11 -8
@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -726,6 +725,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -746,12 +747,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_format (status_text,6 ,"%S" , &link); +rte_eth_link_format (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3897,7 +3900,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=UINT32_MAX && rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3007,14 +3007,7 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) { -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_format (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 3/7] app: UNKNOWN link speed print format
Quoted 4 lines · Ivan Dyukov
Add usage of
rte_eth_link_formatfunction to example applicationsSigned-off-by Ivan Dyukov <[email protected]>
<...>
app/test-pipeline/init.c static void · line 158
Quoted 6 lines
app/test-pipeline/init.c +1
-1@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char status_text[50 ];
I think better to add 'link' to variable name to clarify, like 'link_status' as done in other app, or 'link_status_text' if you prefer, etc...
PATCH v3 4/7 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_format function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char text[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_format(text, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, text); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 4/7] doc: update sample app with unknown speed
Quoted 13 lines · Ivan Dyukov
Add usage of
rte_eth_link_formatfunction to example applicationsSigned-off-by Ivan Dyukov <[email protected]>--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)doc/guides/sample_app_ug/link_status_intr.rst +0
-0
doc/guides/sample_app_ug/link_status_intr.rst An example callback function that has been written as indicated below. · line 161
Quoted 4 lines
doc/guides/sample_app_ug/link_status_intr.rst +1
-0@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char text[200];
similarly, better to say something like 'link_status' instead of just 'text'.
PATCH v3 5/7 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
Hi, dyukov
Quoted 25 lines
-----Original Message-----
From: Ivan Dyukov <[email protected]>
Sent: Monday, June 15, 2020 5:02 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [PATCH v3 5/7] net/ixgbe: return unknown speed in status
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev · line 4319
Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0
-5@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ;
You can not delete these specific code for some kind of ixgbe nic!!!
Quoted 6 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-0+ link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case
IXGBE_LINK_SPEED_100_FULL:
--
2.17.1
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
In reply to Ivan DyukovQuoted 16 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4317
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-5case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
looks good to me.
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
Hi, ferruh
Quoted 26 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, June 18, 2020 12:51 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v3 5/7] net/ixgbe: return unknown speed in statusdrivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct
Quoted 14 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct
rte_eth_dev*dev,
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4318
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0
-5switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ;
For ixgbe x553(IXGBE_DEV_ID_X550EM_A_1G_T), we must do some adaption, we can not delete these specific code for the kind of ixgbe nic.
Quoted 10 lines
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-0+ link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case
IXGBE_LINK_SPEED_100_FULL:looks good to me.
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
Quoted 28 lines · Wei
Hi, ferruh
Quoted 26 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, June 18, 2020 12:51 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v3 5/7] net/ixgbe: return unknown speed in statusdrivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct
Quoted 14 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct
rte_eth_dev*dev,
Quoted 10 lines
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4318
Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0
-5switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || -hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) -link.link_speed =ETH_SPEED_NUM_10M ; -else -link.link_speed =ETH_SPEED_NUM_100M ;For ixgbe
x553(IXGBE_DEV_ID_X550EM_A_1G_T), we must do some adaption, we can not delete these specific code for the kind of ixgbe nic.
Hi Wei,
These checks are done when 'link_speed' is 'IXGBE_LINK_SPEED_UNKNOWN'.
I assume we are setting some default values based on device type when link speed is unknown. Using new 'ETH_SPEED_NUM_UNKNOWN' type when link speed is unknown can be more accurate.
For 'IXGBE_DEV_ID_X550EM_A_1G_T', is link speed 'IXGBE_LINK_SPEED_UNKNOWN' explicitly means 'ETH_SPEED_NUM_10M'?
If so why it doesn't return 'IXGBE_LINK_SPEED_10_FULL' instead?
Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-0+link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case
IXGBE_LINK_SPEED_100_FULL:looks good to me.
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
Hi, Ferruh
Quoted 55 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, June 18, 2020 7:12 PM
To: Zhao1, Wei <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v3 5/7] net/ixgbe: return unknown speed in statusQuoted 14 lines · Wei
Hi, ferruh
Quoted 12 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, June 18, 2020 12:51 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v3 5/7] net/ixgbe: return unknown speed in statusQuoted 1 line · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be usedin
Quoted 14 lines
Quoted 14 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct
Quoted 13 lines
case when no speed information is available
Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +0
-0@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct
rte_eth_dev*dev,Quoted 9 lines
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
Quoted 7 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0
-3switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || -hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) -link.link_speed =ETH_SPEED_NUM_10M ; -else -link.link_speed =ETH_SPEED_NUM_100M ;For ixgbe
x553(IXGBE_DEV_ID_X550EM_A_1G_T), we must do someadaption, we can not delete these specific code for the kind of ixgbe nic.
Hi Wei,
These checks are done when '
link_speed' is 'IXGBE_LINK_SPEED_UNKNOWN'.
Quoted 8 lines
I assume we are setting some default values based on device type when link speed is unknown. Using new '
ETH_SPEED_NUM_UNKNOWN' type when link speed is unknown can be more accurate.For '
IXGBE_DEV_ID_X550EM_A_1G_T', is link speed 'IXGBE_LINK_SPEED_UNKNOWN'
explicitly means 'ETH_SPEED_NUM_10M'?
If so why it doesn't return 'IXGBE_LINK_SPEED_10_FULL' instead?
After do a double check, it seems base code ixgbe_check_mac_link_generic() has do the adaption,
if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T || hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) *speed = IXGBE_LINK_SPEED_10_FULL;
so we only need do some upodate in ixgbe_dev_link_update_share(), add the case IXGBE_LINK_SPEED_10_FULL. So, this patch set is ok now, I think.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4317
Quoted 12 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1
-0+link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :looks good to me.
Re: [dpdk-dev] [PATCH v3 5/7] net/ixgbe: return unknown speed in status
In reply to Ivan DyukovQuoted 40 lines
-----Original Message-----
From: Ivan Dyukov <[email protected]>
Sent: Monday, June 15, 2020 5:02 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: [PATCH v3 5/7] net/ixgbe: return unknown speed in status
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +1
-5@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case
IXGBE_LINK_SPEED_100_FULL:
--
2.17.1
PATCH v3 6/7 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2889,7 +2889,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2165,15 +2165,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 6/7] net/i40e: return unknown speed in status
Quoted 42 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is available and link is up.NUM_NONEshould be returned, if link is down.Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)drivers/net/i40e/i40e_ethdev.c +4
-1@@ -2889,7 +2889,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }drivers/net/i40e/i40e_ethdev_vf.c +4
-1@@ -2165,15 +2165,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
drivers/net/i40e/i40e_ethdev_vf.c i40evf_dev_link_update(struct rte_eth_dev *dev, · line 2179
Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +1
-4/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
lgtm
PATCH v3 7/7 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3112,8 +3112,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 7/7] net/ice: return unknown speed in status
Quoted 17 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is available and link is up.NUM_NONEshould be returned, if link is down.Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ice/ice_ethdev.c +0
-0@@ -3112,8 +3112,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;
drivers/net/ice/ice_ethdev.c ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) · line 3122
Quoted 10 lines
drivers/net/ice/ice_ethdev.c +4
-1case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
v4 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 + app/proc-info/main.c | 9 +- app/test-pipeline/init.c | 11 +- app/test-pmd/config.c | 19 ++- app/test-pmd/testpmd.c | 9 +- app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 278 ++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +-- doc/guides/sample_app_ug/link_status_intr.rst | 10 +- drivers/net/i40e/i40e_ethdev.c | 5 +- drivers/net/i40e/i40e_ethdev_vf.c | 10 +- drivers/net/ice/ice_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +- lib/librte_ethdev/rte_ethdev.c | 168 ++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 74 +++++++-- lib/librte_ethdev/rte_ethdev_version.map | 4 + 17 files changed, 566 insertions(+), 65 deletions(-)
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v4 1/7 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v4 2/7 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 278 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 168 ++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 54 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 510 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -378,6 +378,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -249,6 +249,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -38,6 +38,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -196,6 +197,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status' true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +278 -0
278 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +168 -0
174 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +54 -0
60 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.08 + rte_eth_link_format; + rte_eth_link_printf; };
Signature · 1 line
2.17.1
PATCH v4 3/7 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_format function to example applications
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 19 +++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 27 insertions(+), 38 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_format (link_status_text,50 ,"(%G Gbps) %S" , + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +11 -8
@@ -600,10 +600,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -726,6 +725,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -746,12 +747,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_format (status_text,6 ,"%S" , &link); +rte_eth_link_format (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3897,7 +3900,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=UINT32_MAX && rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3007,14 +3007,7 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) { -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_format (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v4 4/7 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_format function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_format(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v4 5/7 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v4 5/7] net/ixgbe: return unknown speed in status
Quoted 40 lines
-----Original Message-----
From: Ivan Dyukov <[email protected]>
Sent: Thursday, July 2, 2020 9:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Zhao1, Wei <[email protected]>; Guo, Jia <[email protected]>; Xing, Beilei <[email protected]>; Yang, Qiming <[email protected]>; Lu, Wenzhuo <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v4 5/7] net/ixgbe: return unknown speed in status
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is availableSigned-off-by Ivan Dyukov <[email protected]>Reviewed-by Wei Zhao <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ixgbe/ixgbe_ethdev.c +1
-5@@ -4311,11 +4311,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;
Quoted 3 lines
case
IXGBE_LINK_SPEED_100_FULL:
--
2.17.1
PATCH v4 6/7 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2889,7 +2889,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2165,15 +2165,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v4 6/7] net/i40e: return unknown speed in status
Quoted 41 lines · Ivan Dyukov
rte_ethdevhas declared newNUM_UNKNOWNspeed which could be used in case when no speed information is available and link is up.NUM_NONEshould be returned, if link is down.Signed-off-by Ivan Dyukov <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)drivers/net/i40e/i40e_ethdev.c +4
-1@@ -2889,7 +2889,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }drivers/net/i40e/i40e_ethdev_vf.c +4
-1@@ -2165,15 +2165,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
drivers/net/i40e/i40e_ethdev_vf.c i40evf_dev_link_update(struct rte_eth_dev *dev, · line 2179
Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +1
-4/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
PATCH v4 7/7 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3112,8 +3112,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
v5 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 +
app/proc-info/main.c | 9 ++---- app/test-pipeline/init.c | 11 ++++--- app/test-pmd/config.c | 20 ++++++++----- app/test-pmd/testpmd.c | 9 +----- app/test/Makefile | 3 ++ app/test/meson.build | 2 ++ app/test/test_ethdev_link.c | 278 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +++++------ doc/guides/sample_app_ug/link_status_intr.rst | 10 +++---- drivers/net/i40e/i40e_ethdev.c | 5 +++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++---- drivers/net/ice/ice_ethdev.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--- examples/bbdev_app/main.c | 8 ++--- examples/ioat/ioatfwd.c | 13 ++++---- examples/ip_fragmentation/main.c | 13 ++++---- examples/ip_pipeline/cli.c | 12 ++++---- examples/ip_reassembly/main.c | 12 +++----- examples/ipsec-secgw/ipsec-secgw.c | 12 +++----- examples/ipv4_multicast/main.c | 12 +++----- examples/kni/main.c | 26 ++++++---------- examples/l2fwd-crypto/main.c | 12 +++----- examples/l2fwd-event/main.c | 12 +++----- examples/l2fwd-jobstats/main.c | 12 +++----- examples/l2fwd-keepalive/main.c | 12 +++----- examples/l2fwd/main.c | 12 +++----- examples/l3fwd-acl/main.c | 12 +++----- examples/l3fwd-graph/main.c | 14 +++------ examples/l3fwd-power/main.c | 13 +++----- examples/l3fwd/main.c | 12 +++----- examples/link_status_interrupt/main.c | 30 ++++++++----------- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++++----- examples/multi_process/symmetric_mp/main.c | 12 +++----- examples/ntb/ntb_fwd.c | 10 +++---- examples/performance-thread/l3fwd-thread/main.c | 12 +++----- examples/qos_sched/init.c | 10 ++----- examples/server_node_efd/server/init.c | 15 ++++------ examples/vm_power_manager/main.c | 14 ++++----- lib/librte_ethdev/rte_ethdev.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 74 +++++++++++++++++++++++++++++++++++++++------- lib/librte_ethdev/rte_ethdev_version.map | 4 +++ 42 files changed, 687 insertions(+), 282 deletions(-)
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v5 1/25 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v5 2/25 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 278 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 169 ++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 54 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 511 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status' true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +278 -0
278 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +169 -0
175 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +54 -0
60 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.08 + rte_eth_link_strf; + rte_eth_link_printf; };
Signature · 1 line
2.17.1
PATCH v5 3/25 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 28 insertions(+), 38 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_strf (link_status_text,50 ,"(%G Gbps) %S" , + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +12 -8
@@ -604,10 +604,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -730,6 +729,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -750,12 +751,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_strf (status_text,6 ,"%S" , &link); +rte_eth_link_strf (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3899,7 +3902,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3010,14 +3010,7 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) { -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_strf (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 4/25 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_strf(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v5 5/25 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v5 6/25 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v5 7/25 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v5 8/25 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 12 ++++------- examples/l2fwd-jobstats/main.c | 12 ++++------- examples/l2fwd-keepalive/main.c | 12 ++++------- examples/l3fwd/main.c | 12 ++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 28 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +4 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -591,14 +592,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-jobstats/main.c +4 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -708,14 +709,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-keepalive/main.c +4 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -472,14 +473,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd/main.c +4 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -833,14 +834,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps -%s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/link_status_interrupt/main.c +12 -18
@@ -118,6 +118,7 @@ print_stats(void)const char clr[] = {27 ,'[' ,'2' ,'J' ,'\0' };const char topLeft[] = {27 ,'[' ,'1' ,';' ,'1' ,'H' ,'\0' };int link_get_err; +char link_speed_text[16 ];/* Clear screen and move to top left */ printf ("%s%s" , clr, topLeft);
@@ -131,9 +132,10 @@ print_stats(void)memset (&link,0 ,sizeof (link)); link_get_err =rte_eth_link_get_nowait (portid, &link); +rte_eth_link_strf (link_speed_text,16 ,"%M" , &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : link_speed_text, link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[60 ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +459,8 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, port_id, rte_strerror(-ret));return ret; } -if (link.link_status) { -printf ("Port %d Link Up - speed %u Mbps - %s\n\n" , - port_id, (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 9/25 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/bbdev_app/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
examples/bbdev_app/main.c +3 -5
@@ -313,6 +313,7 @@ check_port_link_status(uint16_t port_id)uint8_t count;struct rte_eth_link link;int link_get_err = -EINVAL ; +char link_status_text[60 ];printf ("\nChecking link status." );fflush (stdout);
@@ -323,11 +324,8 @@ check_port_link_status(uint16_t port_id) link_get_err =rte_eth_link_get_nowait (port_id, &link);if (link_get_err >=0 && link.link_status) { -const char *dp = (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? -"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("\nPort %u %s" , port_id, link_status_text);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v5 10/25 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ioat/ioatfwd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +5 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[60 ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,11 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1
PATCH v5 11/25 examples/ip_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ip_fragmentation
* ip_reassembly
* l3fwd-acl
--- examples/ip_fragmentation/main.c | 13 +++++-------- examples/ip_reassembly/main.c | 12 ++++-------- examples/l3fwd-acl/main.c | 12 ++++-------- 3 files changed, 13 insertions(+), 24 deletions(-)
examples/ip_fragmentation/main.c +5 -8
@@ -593,6 +593,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -612,14 +613,10 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up .Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/ip_reassembly/main.c +4 -8
@@ -712,6 +712,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -731,14 +732,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd-acl/main.c +4 -8
@@ -1815,6 +1815,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1834,14 +1835,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 12/25 examples/ip_pipeline: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ip_pipeline/cli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
examples/ip_pipeline/cli.c +7 -5
@@ -249,7 +249,8 @@ print_link_info(struct link *link, char *out, size_t out_size)struct rte_eth_link eth_link;uint16_t mtu;int ret; - +char link_speed_text[16 ]; +char link_status_text[10 ];memset (&stats,0 ,sizeof (stats));rte_eth_stats_get (link->port_id, &stats);
@@ -268,18 +269,19 @@ print_link_info(struct link *link, char *out, size_t out_size) }rte_eth_dev_get_mtu (link->port_id, &mtu); - +rte_eth_link_strf (link_speed_text,16 ,"%M" , ð_link); +rte_eth_link_strf (link_status_text,10 ,"%S" , ð_link); snprintf(out, out_size, "\n" "%s: flags=<%s> mtu %u\n" "\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n" - "\tport# %u speed %u Mbps\n" + "\tport# %u speed %s Mbps\n" "\tRX packets %" PRIu64" bytes %" PRIu64"\n" "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n" "\tTX packets %" PRIu64" bytes %" PRIu64"\n" "\tTX errors %" PRIu64"\n", link->name, - eth_link.link_status == 0 ? "DOWN" : "UP", + link_status_text, mtu, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
@@ -287,7 +289,7 @@ print_link_info(struct link *link, char *out, size_t out_size) link->n_rxq, link->n_txq, link->port_id, - eth_link.link_speed, + link_speed_text, stats.ipackets, stats.ibytes, stats.ierrors,
Signature · 1 line
2.17.1
PATCH v5 13/25 examples/ipsec-secgw: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ipsec-secgw/ipsec-secgw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +4 -8
@@ -1775,6 +1775,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1794,14 +1795,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up - speed %u Mbps -%s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 14/25 examples/kni: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/kni/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
examples/kni/main.c +9 -17
@@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status\n" );fflush (stdout);
@@ -680,14 +681,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up - speed %uMbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@ check_all_ports_link_status(uint32_t port_mask)static void log_link_state (struct rte_kni *kni,int prev,struct rte_eth_link *link) { +char link_status_text[60 ];if (kni ==NULL || link ==NULL )return ; -if (prev ==ETH_LINK_DOWN && link->link_status ==ETH_LINK_UP ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Up %d Mbps %s %s.\n" , +rte_eth_link_strf (link_status_text,60 ,NULL , link); +if (prev != link->link_status) +RTE_LOG (INFO ,APP ,"%s NIC %s" ,rte_kni_get_name (kni), - link->link_speed, - link->link_autoneg ?"(AutoNeg)" :"(Fixed)" , - link->link_duplex ?"Full Duplex" :"Half Duplex" ); - }else if (prev ==ETH_LINK_UP && link->link_status ==ETH_LINK_DOWN ) { -RTE_LOG (INFO ,APP ,"%s NIC Link is Down.\n" , -rte_kni_get_name (kni)); - } + link_status_text); }/*
Signature · 1 line
2.17.1
PATCH v5 15/25 examples/l2fwd-crypt: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-crypto/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-crypto/main.c +4 -8
@@ -1734,6 +1734,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1753,14 +1754,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 16/25 examples/l2fwd-event: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd-event/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd-event/main.c +4 -8
@@ -366,6 +366,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status..." );fflush (stdout);
@@ -389,14 +390,9 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - port_id, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , port_id, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 17/25 examples/l2fwd: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l2fwd/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/l2fwd/main.c +4 -8
@@ -571,6 +571,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -594,14 +595,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 18/25 examples/l3fwd-graph: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-graph/main.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
examples/l3fwd-graph/main.c +4 -10
@@ -599,6 +599,7 @@ check_all_ports_link_status(uint32_t port_mask)struct rte_eth_link link;uint16_t portid;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -623,16 +624,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* Print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ("Port%d Link Up. Speed %u Mbps " -"-%s\n" , - portid, link.link_speed, - (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) - ? ("full-duplex" ) - : ("half-duplex\n" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* Clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 19/25 examples/l3fwd-power: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/l3fwd-power/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
examples/l3fwd-power/main.c +4 -9
@@ -1945,6 +1945,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -1964,15 +1965,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ("Port %d Link Up - speed %u " -"Mbps - %s\n" , (uint8_t )portid, - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 20/25 examples/multi_proc*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- .../client_server_mp/mp_server/init.c | 14 +++++--------- examples/multi_process/symmetric_mp/main.c | 12 ++++-------- 2 files changed, 9 insertions(+), 17 deletions(-)
examples/multi_process/client_server_mp/mp_server/init.c +5 -9
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -204,15 +205,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ("Port %d Link Up - speed %u " -"Mbps - %s\n" , ports->id[portid], - (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint8_t )ports->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , (uint8_t )ports->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/multi_process/symmetric_mp/main.c +4 -8
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -384,14 +385,9 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 21/25 examples/ntb: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ntb/ntb_fwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
examples/ntb/ntb_fwd.c +5 -5
@@ -729,6 +729,7 @@ start_pkt_fwd(void)struct rte_eth_link eth_link;uint32_t lcore_id;int ret, i; +char link_status_text[60 ]; ret =ntb_fwd_config_setup ();if (ret <0 ) {
@@ -747,11 +748,10 @@ start_pkt_fwd(void)return ; }if (eth_link.link_status) { -printf ("Eth%u Link Up. Speed %u Mbps - %s\n" , - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Eth%u %s" , eth_port_id, + link_status_text);break ; } }
Signature · 1 line
2.17.1
PATCH v5 22/25 example/performance*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/performance-thread/l3fwd-thread/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
examples/performance-thread/l3fwd-thread/main.c +4 -8
@@ -3433,6 +3433,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -3452,14 +3453,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 23/25 examples/qos_sched: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/qos_sched/init.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
examples/qos_sched/init.c +2 -8
@@ -160,14 +160,8 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)"rte_eth_link_get: err=%d, port=%u: %s\n" , ret, portid, rte_strerror(-ret)); -if (link.link_status) { -printf (" Link Up - speed %u Mbps - %s\n" , - (uint32_t ) link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else { -printf (" Link Down\n" ); - } +rte_eth_link_printf (NULL , &link); + ret =rte_eth_promiscuous_enable (portid);if (ret !=0 ) rte_exit(EXIT_FAILURE,
Signature · 1 line
2.17.1
PATCH v5 24/25 examples/server_nod*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/server_node_efd/server/init.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
examples/server_node_efd/server/init.c +5 -10
@@ -247,6 +247,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -266,16 +267,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - info->id[portid], - link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - info->id[portid]); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , info->id[portid], + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v5 25/25 examples/vm_power_*: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/vm_power_manager/main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
examples/vm_power_manager/main.c +5 -9
@@ -244,6 +244,7 @@ check_all_ports_link_status(uint32_t port_mask)uint16_t portid, count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -267,15 +268,10 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ("Port %d Link Up - speed %u " -"Mbps - %s\n" , (uint16_t )portid, - (unsigned int )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , - (uint16_t )portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
v6 cover ethdev: allow unknown link speed
In reply to Ivan DyukovMAINTAINERS | 1 +
app/proc-info/main.c | 9 ++---- app/test-pipeline/init.c | 11 ++++--- app/test-pmd/config.c | 20 ++++++++----- app/test-pmd/testpmd.c | 9 +----- app/test/Makefile | 3 ++ app/test/meson.build | 2 ++ app/test/test_ethdev_link.c | 278 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/test/test_pmd_perf.c | 17 +++++------ doc/guides/sample_app_ug/link_status_intr.rst | 10 +++---- drivers/net/i40e/i40e_ethdev.c | 5 +++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++---- drivers/net/ice/ice_ethdev.c | 5 +++- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +--- examples/bbdev_app/main.c | 8 ++--- examples/ioat/ioatfwd.c | 13 ++++---- examples/ip_fragmentation/main.c | 13 ++++---- examples/ip_pipeline/cli.c | 12 ++++---- examples/ip_reassembly/main.c | 12 +++----- examples/ipsec-secgw/ipsec-secgw.c | 12 +++----- examples/ipv4_multicast/main.c | 12 +++----- examples/kni/main.c | 26 ++++++---------- examples/l2fwd-crypto/main.c | 12 +++----- examples/l2fwd-event/main.c | 12 +++----- examples/l2fwd-jobstats/main.c | 12 +++----- examples/l2fwd-keepalive/main.c | 12 +++----- examples/l2fwd/main.c | 12 +++----- examples/l3fwd-acl/main.c | 12 +++----- examples/l3fwd-graph/main.c | 14 +++------ examples/l3fwd-power/main.c | 13 +++----- examples/l3fwd/main.c | 12 +++----- examples/link_status_interrupt/main.c | 30 ++++++++----------- examples/multi_process/client_server_mp/mp_server/init.c | 14 ++++----- examples/multi_process/symmetric_mp/main.c | 12 +++----- examples/ntb/ntb_fwd.c | 10 +++---- examples/performance-thread/l3fwd-thread/main.c | 12 +++----- examples/qos_sched/init.c | 10 ++----- examples/server_node_efd/server/init.c | 15 ++++------ examples/vm_power_manager/main.c | 14 ++++----- lib/librte_ethdev/rte_ethdev.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 74 +++++++++++++++++++++++++++++++++++++++------- lib/librte_ethdev/rte_ethdev_version.map | 4 +++ 42 files changed, 687 insertions(+), 282 deletions(-)
v6 changes:
* fix spelling in comments according to checkpatch warning
v5 changes:
* rename rte_eth_link_format to rte_eth_link_strf
* add '\n' to default strings
* update remaining examples. patch with subj 'examples: new link status print format' contains examples which have no maintainers. TBD:
update remaining nic drivers with 'unknown' speed. It should be provided in separate patchset.
v4 changes:
* refactor rte_eth_link_format using strlcat func instead of snprintf
* added new checks to unit tests
* few minor fixes according review comments
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v3 changes:
* remove rte_eth_link_prepare_text function
* add rte_eth_link_format and rte_eth_link_printf functions
* added unit tests for rte_eth_link_format function
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v2 changes:
* add function which format link status to textual representation
* update drivers for Intel nics with 'unknown' speed
TBD:
update examples in 'example' folder with new status printing mechanism update remaining nic drivers with 'unknown' speed
v1 changes:
This is initial patchset which introduces UNKNOWN speed to dpdk applications. Also it contains changes related to printf formating. Patchset contains changes for app/ and doc/ folders. examples/ folder will be provided later.
PATCH v6 1/25 ethdev: allow unknown link speed
From: Thomas Monjalon <[email protected]>
When querying the link information, the link status is a mandatory major information.
Other boolean values are supposed to be accurate:
- duplex mode (half/full)
- negotiation (auto/fixed)
This API update is making explicit that the link speed information is optional.
The value ETH_SPEED_NUM_NONE (0) was already part of the API. The value ETH_SPEED_NUM_UNKNOWN (infinite) is added to cover two different cases:
- speed is not known by the driver
- device is virtual
--- lib/librte_ethdev/rte_ethdev.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/librte_ethdev/rte_ethdev.h +10 -10
@@ -303,6 +303,7 @@ struct rte_eth_stats {#define ETH_SPEED_NUM_56G 56000/**< 56 Gbps */ #define ETH_SPEED_NUM_100G 100000/**< 100 Gbps */ #define ETH_SPEED_NUM_200G 200000/**< 200 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN UINT32_MAX/**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port.
@@ -2262,15 +2263,16 @@ int rte_eth_allmulticast_disable(uint16_t port_id);int rte_eth_allmulticast_get (uint16_t port_id);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It might need -* to wait up to 9 seconds in it. +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). +* +* It might need to wait up to 9 seconds. +* @see rte_eth_link_get_nowait. * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
@@ -2279,15 +2281,13 @@ int rte_eth_allmulticast_get(uint16_t port_id);int rte_eth_link_get (uint16_t port_id,struct rte_eth_link *link);/** -* Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX -* or FULL-DUPLEX) of the physical link of an Ethernet device. It is a no-wait -* version of rte_eth_link_get(). +* Retrieve the link status (up/down), the duplex mode (half/full), +* the negotiation (auto/fixed), and if available, the speed (Mbps). * * @param port_id * The port identifier of the Ethernet device. * @param link -* A pointer to an *rte_eth_link* structure to be filled with -* the status, the speed and the mode of the Ethernet device link. +* Link information written back. * @return * - (0) if successful. * - (-ENOTSUP) if the function is not supported in PMD driver.
Signature · 1 line
2.17.1
PATCH v6 2/25 ethdev: add a link status text representation
In reply to Ivan DyukovThis commit add function which treat link status structure and format it to text representation.
--- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 278 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 169 ++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 54 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 511 insertions(+) create mode 100644 app/test/test_ethdev_link.c
MAINTAINERS +1 -0
@@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam <[email protected]>
app/test/Makefile +3 -0
@@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif
app/test/meson.build +2 -0
@@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c',
@@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status' true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true],
app/test/test_ethdev_link.c new file +278 -0
278 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.c +169 -0
175 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +54 -0
60 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.08 + rte_eth_link_strf; + rte_eth_link_printf; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v6 02/25] ethdev: add a link status text representation
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2388
Quoted 3 lines · On Mon, 6 Jul 2020 23:37:16 +0300 Ivan Dyukov <[email protected]> wrote:
static int
lib/librte_ethdev/rte_ethdev.c +2
-0+rte_eth_link_strf_parser(char *str, size_t len, const char *const fmt, + struct rte_eth_link *link)
The link arg should be const.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2400
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12
-0+{ +size_t offset =0 ; +const char *fmt_cur = fmt; +char *str_cur = str; +double gbits = (double )link->link_speed /1000. ; +static const char AUTONEG_STR [] ="Autoneg" ; +static const char FIXED_STR [] ="Fixed" ; +static const char FDX_STR [] ="FDX" ; +static const char HDX_STR [] ="HDX" ; +static const char UNKNOWN_STR [] ="Unknown" ; +static const char UP_STR [] ="Up" ; +static const char DOWN_STR [] ="Down" ;
Why are these UPPER_CASE_CONSTANTS? That does not match DPDK style.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2404
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+ +char gbits_str[20 ]; +char mbits_str[20 ]; +/* preformat complex formatting to easily concatinate it further */
Blank line between declaration and code.
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2406
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+snprintf (mbits_str,20 ,"%u" , link->link_speed); +snprintf (gbits_str,20 ,"%.1f" , gbits);
Use sizeof(mbits_str) which is safer and matches what youare doing.
Quoted 63 lines
lib/librte_ethdev/rte_ethdev.c +63
-0+/* init str before formatting */ + str[0 ] =0 ; +while (*fmt_cur) { +/* check str bounds */ +if (offset > (len -1 )) { + str[len -1 ] ='\0' ; +return -1 ; + } +if (*fmt_cur =='%' ) { +/* set null terminator to current position, +* it's required for strlcat +*/ + *str_cur ='\0' ; +switch (*++fmt_cur) { +/* Speed in Mbits/s */ +case 'M' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str,UNKNOWN_STR , + len); +else + offset =strlcat (str, mbits_str, len); +break ; +/* Speed in Gbits/s */ +case 'G' : +if (link->link_speed == +ETH_SPEED_NUM_UNKNOWN ) + offset =strlcat (str,UNKNOWN_STR , + len); +else + offset =strlcat (str, gbits_str, len); +break ; +/* Link status */ +case 'S' : + offset =strlcat (str, link->link_status ? +UP_STR :DOWN_STR , len); +break ; +/* Link autoneg */ +case 'A' : + offset =strlcat (str, link->link_autoneg ? +AUTONEG_STR :FIXED_STR , len); +break ; +/* Link duplex */ +case 'D' : + offset =strlcat (str, link->link_duplex ? +FDX_STR :HDX_STR , len); +break ; +/* Error cases */ +default : +return -1 ; + + } +if (offset > (len -1 )) +return -1 ; + + str_cur = str + offset; + }else { + *str_cur++ = *fmt_cur; + offset++; + } + fmt_cur++; + } + *str_cur ='\0' ;
lib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2479
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+return offset; +} + +int +rte_eth_link_printf (const char *const fmt, +struct rte_eth_link *link) +{ +char text[200 ]; +int ret; + ret =rte_eth_link_strf (text,200 , fmt, link);
Blank line tween declaration and code.
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+if (ret >0 ) +printf ("%s" , text); +return ret; +}
Re: [dpdk-dev] [PATCH v6 02/25] ethdev: add a link status text representation
In reply to Ivan Dyukovlib/librte_ethdev/rte_ethdev.c rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) · line 2457
Quoted 4 lines · On Mon, 6 Jul 2020 23:37:16 +0300 Ivan Dyukov <[email protected]> wrote:
lib/librte_ethdev/rte_ethdev.c +4
-0+/* Error cases */ +default : +return -1 ; +
Since very little of the code is checking for errors, why return on bad format. Why not do what printf() does and ignore what is not specified.
Example:
r = printf("Wierd %W format\n", x);
printf("returned %d\n", r);Wierd %W format
returned 16
PATCH v6 3/25 app: UNKNOWN link speed print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 28 insertions(+), 38 deletions(-)
app/proc-info/main.c +3 -6
@@ -685,12 +685,9 @@ show_port(void)printf ("Link get failed (port %u): %s\n" , i,rte_strerror (-ret)); }else { -printf ("\t -- link speed %d duplex %d," -" auto neg %d status %d\n" , - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); +rte_eth_link_printf ("\t -- link speed: %M, duplex: %D," +" auto neg: %A, status: %S\n" , + &link); }printf ("\t -- promiscuous (%d)\n" ,rte_eth_promiscuous_get (i));
app/test-pipeline/init.c +5 -6
@@ -155,7 +155,7 @@ static voidapp_ports_check_link (void) {uint32_t all_ports_up, i; - +char link_status_text[50 ]; all_ports_up =1 ;for (i =0 ; i < app.n_ports; i++) {
@@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up =0 ;continue ; } - -RTE_LOG (INFO ,USER1 ,"Port %u (%u Gbps) %s\n" , +rte_eth_link_strf (link_status_text,50 ,"(%G Gbps) %S" , + &link); +RTE_LOG (INFO ,USER1 ,"Port %u %s\n" , port, - link.link_speed /1000 , - link.link_status ?"UP" :"DOWN" ); - + link_status_text);if (link.link_status ==ETH_LINK_DOWN ) all_ports_up =0 ; }
app/test-pmd/config.c +12 -8
@@ -604,10 +604,9 @@ port_infos_display(portid_t port_id) }else printf ("\nmemory allocation on the socket: %u" ,port->socket_id); -printf ("\nLink status: %s\n" , (link.link_status) ? ("up" ) : ("down" )); -printf ("Link speed: %u Mbps\n" , (unsigned ) link.link_speed); -printf ("Link duplex: %s\n" , (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_printf ("\nLink status: %S\n" +"Link speed: %M Mbps\n" +"Link duplex: %D\n" , &link);if (!rte_eth_dev_get_mtu (port_id, &mtu))printf ("MTU: %u\n" , mtu);
@@ -730,6 +729,8 @@ port_summary_display(portid_t port_id)struct rte_eth_link link;struct rte_eth_dev_info dev_info;char name[RTE_ETH_NAME_MAX_LEN ]; +char status_text[6 ]; +char speed_text[12 ];int ret;if (port_id_is_invalid (port_id,ENABLED_WARN )) {
@@ -750,12 +751,14 @@ port_summary_display(portid_t port_id)if (ret !=0 )return ; -printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n" , +rte_eth_link_strf (status_text,6 ,"%S" , &link); +rte_eth_link_strf (speed_text,12 ,"%M" , &link); +printf ("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n" , port_id, mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ], name, - dev_info.driver_name, (link.link_status) ? ("up" ) : ("down" ), - (unsigned int ) link.link_speed); + dev_info.driver_name, status_text, + speed_text); }void
@@ -3899,7 +3902,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret =eth_link_get_nowait_print_err (port_id, &link);if (ret <0 )return 1 ; -if (rate > link.link_speed) { +if (link.link_speed !=ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) {printf ("Invalid rate value:%u bigger than link speed: %u\n" , rate, link.link_speed);return 1 ;
app/test-pmd/testpmd.c +1 -8
@@ -3010,14 +3010,7 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. speed %u Mbps- %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_printf (NULL , &link);continue ; }/* clear all_ports_up flag if any link down */
app/test/test_pmd_perf.c +7 -10
@@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status[50 ];printf ("Checking link statuses...\n" );fflush (stdout);
@@ -146,16 +147,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) { -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -if (link_mbps ==0 ) - link_mbps = link.link_speed; - }else -printf ("Port %d Link Down\n" , portid); +if (link.link_status && link_mbps ==0 ) + link_mbps = link.link_speed; + +rte_eth_link_strf (link_status,50 ,NULL , + &link); +printf ("Port %d %s\n" , portid, link_status);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v6 03/25] app: UNKNOWN link speed print format
app/proc-info/main.c show_port(void) · line 689
Quoted 2 lines · On Mon, 6 Jul 2020 23:37:17 +0300 Ivan Dyukov <[email protected]> wrote:
app/proc-info/main.c +2
-0+ rte_eth_link_printf("\t -- link speed: %M, duplex: %D," + " auto neg: %A, status: %S\n",
Don't break lines in middle of strings. It makes it hard for users who are doing grep to look for error messages.
PATCH v6 4/25 doc: update sample app with unknown speed
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
doc/guides/sample_app_ug/link_status_intr.rst +5 -5
@@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param);
@@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + } else { + rte_eth_link_strf(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port.
Signature · 1 line
2.17.1
PATCH v6 5/25 net/ixgbe: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available
--- drivers/net/ixgbe/ixgbe_ethdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -5
@@ -4300,11 +4300,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,switch (link_speed) {default :case IXGBE_LINK_SPEED_UNKNOWN : -if (hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T || - hw->device_id ==IXGBE_DEV_ID_X550EM_A_1G_T_L ) - link.link_speed =ETH_SPEED_NUM_10M ; -else - link.link_speed =ETH_SPEED_NUM_100M ; + link.link_speed =ETH_SPEED_NUM_UNKNOWN ;break ;case IXGBE_LINK_SPEED_100_FULL :
Signature · 1 line
2.17.1
PATCH v6 6/25 net/i40e: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/i40e/i40e_ethdev.c | 5 ++++- drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/net/i40e/i40e_ethdev.c +4 -1
@@ -2891,7 +2891,10 @@ update_link_aq(struct i40e_hw *hw, struct rte_eth_link *link, link->link_speed =ETH_SPEED_NUM_40G ;break ;default : - link->link_speed =ETH_SPEED_NUM_NONE ; +if (link->link_status) + link->link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + link->link_speed =ETH_SPEED_NUM_NONE ;break ; } }
drivers/net/i40e/i40e_ethdev_vf.c +5 -5
@@ -2163,15 +2163,15 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_speed =ETH_SPEED_NUM_40G ;break ;default : - new_link.link_speed =ETH_SPEED_NUM_NONE ; +if (vf->link_up) + new_link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +else + new_link.link_speed =ETH_SPEED_NUM_NONE ;break ; }/* full duplex only */ new_link.link_duplex =ETH_LINK_FULL_DUPLEX ; - new_link.link_status = vf->link_up && - new_link.link_speed !=ETH_SPEED_NUM_NONE - ?ETH_LINK_UP - :ETH_LINK_DOWN ; + new_link.link_status = vf->link_up ?ETH_LINK_UP :ETH_LINK_DOWN ; new_link.link_autoneg = !(dev->data->dev_conf.link_speeds Ð_LINK_SPEED_FIXED );
Signature · 1 line
2.17.1
PATCH v6 7/25 net/ice: return unknown speed in status
In reply to Ivan Dyukovrte_ethdev has declared new NUM_UNKNOWN speed which could be used in case when no speed information is available and link is up. NUM_NONE should be returned, if link is down.
--- drivers/net/ice/ice_ethdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.c +4 -1
@@ -3135,8 +3135,11 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) link.link_speed =ETH_SPEED_NUM_100G ;break ;case ICE_AQ_LINK_SPEED_UNKNOWN : -default :PMD_DRV_LOG (ERR ,"Unknown link speed" ); + link.link_speed =ETH_SPEED_NUM_UNKNOWN ; +break ; +default : +PMD_DRV_LOG (ERR ,"None link speed" ); link.link_speed =ETH_SPEED_NUM_NONE ;break ; }
Signature · 1 line
2.17.1
PATCH v6 8/25 examples: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
--- examples/ipv4_multicast/main.c | 12 ++++------- examples/l2fwd-jobstats/main.c | 12 ++++------- examples/l2fwd-keepalive/main.c | 12 ++++------- examples/l3fwd/main.c | 12 ++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 28 insertions(+), 50 deletions(-)
examples/ipv4_multicast/main.c +4 -8
@@ -572,6 +572,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -591,14 +592,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-jobstats/main.c +4 -8
@@ -689,6 +689,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -708,14 +709,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l2fwd-keepalive/main.c +4 -8
@@ -453,6 +453,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -472,14 +473,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/l3fwd/main.c +4 -8
@@ -810,6 +810,7 @@ check_all_ports_link_status(uint32_t port_mask)uint8_t count, all_ports_up, print_flag =0 ;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -833,14 +834,9 @@ check_all_ports_link_status(uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps -%s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, link_status_text);continue ; }/* clear all_ports_up flag if any link down */
examples/link_status_interrupt/main.c +12 -18
@@ -118,6 +118,7 @@ print_stats(void)const char clr[] = {27 ,'[' ,'2' ,'J' ,'\0' };const char topLeft[] = {27 ,'[' ,'1' ,';' ,'1' ,'H' ,'\0' };int link_get_err; +char link_speed_text[16 ];/* Clear screen and move to top left */ printf ("%s%s" , clr, topLeft);
@@ -131,9 +132,10 @@ print_stats(void)memset (&link,0 ,sizeof (link)); link_get_err =rte_eth_link_get_nowait (portid, &link); +rte_eth_link_strf (link_speed_text,16 ,"%M" , &link);printf ("\nStatistics for port %u ------------------------------" "\nLink status: %25s" -"\nLink speed: %26u" +"\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24" PRIu64 "\nPackets received: %20"PRIu64
@@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err <0 ?"Link get failed" : (link.link_status ?"Link up" :"Link down" ), - link_get_err <0 ?0 : - (unsigned int )link.link_speed, + link_get_err <0 ?"0" : link_speed_text, link_get_err <0 ?"Link get failed" : (link.link_duplex ==ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"),
@@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, {struct rte_eth_link link;int ret; +char link_status_text[60 ];RTE_SET_USED (param);RTE_SET_USED (ret_param);
@@ -457,13 +459,8 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, port_id, rte_strerror(-ret));return ret; } -if (link.link_status) { -printf ("Port %d Link Up - speed %u Mbps - %s\n\n" , - port_id, (unsigned )link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); - }else -printf ("Port %d Link Down\n\n" , port_id); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s\n" , port_id, link_status_text);return 0 ; }
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret; +char link_status_text[60 ];printf ("\nChecking link status" );fflush (stdout);
@@ -497,14 +495,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) }/* print link status if flag set */ if (print_flag ==1 ) { -if (link.link_status) -printf ( -"Port%d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); -else -printf ("Port %d Link Down\n" , portid); +rte_eth_link_strf (link_status_text,60 ,NULL , + &link); +printf ("Port %d %s" , portid, + link_status_text);continue ; }/* clear all_ports_up flag if any link down */
Signature · 1 line
2.17.1
PATCH v6 9/25 examples/bbdev_app: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/bbdev_app/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
examples/bbdev_app/main.c +3 -5
@@ -313,6 +313,7 @@ check_port_link_status(uint16_t port_id)uint8_t count;struct rte_eth_link link;int link_get_err = -EINVAL ; +char link_status_text[60 ];printf ("\nChecking link status." );fflush (stdout);
@@ -323,11 +324,8 @@ check_port_link_status(uint16_t port_id) link_get_err =rte_eth_link_get_nowait (port_id, &link);if (link_get_err >=0 && link.link_status) { -const char *dp = (link.link_duplex == -ETH_LINK_FULL_DUPLEX ) ? -"full-duplex" :"half-duplex" ; -printf ("\nPort %u Link Up - speed %u Mbps - %s\n" , - port_id, link.link_speed, dp); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("\nPort %u %s" , port_id, link_status_text);return 0 ; }printf ("." );
Signature · 1 line
2.17.1
PATCH v6 10/25 examples/ioat: new link status print format
In reply to Ivan DyukovAdd usage of rte_eth_link_strf function to example applications
--- examples/ioat/ioatfwd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
examples/ioat/ioatfwd.c +5 -8
@@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)uint16_t portid;struct rte_eth_link link;int ret, link_status =0 ; +char link_status_text[60 ];printf ("\nChecking link status\n" );RTE_ETH_FOREACH_DEV (portid) {
@@ -715,15 +716,11 @@ check_link_status(uint32_t port_mask) }/* Print link status */ -if (link.link_status) { -printf ( -"Port %d Link Up. Speed %u Mbps - %s\n" , - portid, link.link_speed, - (link.link_duplex ==ETH_LINK_FULL_DUPLEX ) ? - ("full-duplex" ) : ("half-duplex" )); +rte_eth_link_strf (link_status_text,60 ,NULL , &link); +printf ("Port %d %s" , portid, link_status_text); + +if (link.link_status) link_status =1 ; - }else -printf ("Port %d Link Down\n" , portid); }return link_status; }
Signature · 1 line
2.17.1