failsafe: add xstats
cover failsafe: add xstats
A useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 144 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_core.h | 14 +++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 4 files changed, 169 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 ethdev: expose basic xstats for driver use
From: Stephen Hemminger <[email protected]>
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 ++++++++--------- lib/librte_ethdev/rte_ethdev_core.h | 14 ++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 3 files changed, 25 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_core.h +14 -0
@@ -517,6 +517,20 @@ struct eth_dev_ops {/**< Test if a port supports specific mempool ops */ }; +/** +* @internal +* Get basic stats for ethdev +*/ +int __rte_experimental +rte_eth_basic_stats_count (struct rte_eth_dev *dev); + +int __rte_experimental +rte_eth_basic_stats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names); + +int __rte_experimental +rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats); +/** * @internal * Structure used to hold information about the callbacks to be called for a
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -239,6 +239,9 @@ DPDK_19.05 { EXPERIMENTAL { global: + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; rte_eth_devargs_parse; rte_eth_dev_create; rte_eth_dev_destroy;
Signature · 1 line
2.20.1
PATCH 2/2 failsafe: implement xstats
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Add support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+)
drivers/net/failsafe/failsafe_ops.c +144 -0
@@ -789,6 +789,147 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +int r, count; +uint8_t i; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +if (sdev->state <DEV_ACTIVE ) +continue ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +uint8_t i; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +int j,r; + +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (sdev->state <DEV_ACTIVE ) +continue ; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + count < limit ? limit - count:0 ); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (j =0 ; j < r; j++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[j].name); +memcpy (sub_names[j].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +if (sdev->state <DEV_ACTIVE ) +continue ; + + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1374,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.20.1
v2 cover failsafe: add xstats
In reply to Stephen HemmingerA useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v2 - fix checkpatch complaints
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 130 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_core.h | 14 +++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 4 files changed, 155 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 ethdev: expose basic xstats for driver use
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 ++++++++--------- lib/librte_ethdev/rte_ethdev_core.h | 14 ++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 3 files changed, 25 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_core.h +14 -0
@@ -517,6 +517,20 @@ struct eth_dev_ops {/**< Test if a port supports specific mempool ops */ }; +/** +* @internal +* Get basic stats for ethdev +*/ +int __rte_experimental +rte_eth_basic_stats_count (struct rte_eth_dev *dev); + +int __rte_experimental +rte_eth_basic_stats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names); + +int __rte_experimental +rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats); +/** * @internal * Structure used to hold information about the callbacks to be called for a
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -239,6 +239,9 @@ DPDK_19.05 { EXPERIMENTAL { global: + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; rte_eth_devargs_parse; rte_eth_dev_create; rte_eth_dev_destroy;
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 1/2] ethdev: expose basic xstats for driver use
Quoted 5 lines · Stephen Hemminger
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
Signed-off-by Stephen Hemminger <[email protected]>
[...]
Quoted 15 lines
lib/librte_ethdev/rte_ethdev_core.h +7
-0@@ -517,6 +517,20 @@ struct eth_dev_ops {/**< Test if a port supports specific mempool ops */ }; +/** +* @internal +* Get basic stats for ethdev +*/ +int __rte_experimental +rte_eth_basic_stats_count (struct rte_eth_dev *dev); +
lib/librte_ethdev/rte_ethdev_core.h struct eth_dev_ops { · line 536
Quoted 10 lines
lib/librte_ethdev/rte_ethdev_core.h +7
-0+int __rte_experimental +rte_eth_basic_stats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names); + +int __rte_experimental +rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats); +/** * @internal * Structure used to hold information about the callbacks to be called for a
It conflicts with __rte_experimenal placing patch which is on the mailing list. Also I've expected to see these functions in rte_ethdev_driver.h to avoid inclusion in rte_ethdev.h. As I understand these functions are for rte_ethdev and drivers only.
Quoted 14 lines
lib/librte_ethdev/rte_ethdev_version.map +3
-0@@ -239,6 +239,9 @@ DPDK_19.05 { EXPERIMENTAL { global: + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; rte_eth_devargs_parse; rte_eth_dev_create; rte_eth_dev_destroy;
Re: [dpdk-dev] [PATCH v2 1/2] ethdev: expose basic xstats for driver use
Quoted 33 lines · On Mon, 1 Jul 2019 13:54:52 +0300 Andrew Rybchenko <[email protected]>…
Quoted 5 lines · Stephen Hemminger
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
Signed-off-by Stephen Hemminger <[email protected]>[...]
Quoted 23 lines
lib/librte_ethdev/rte_ethdev_core.h +14
-0@@ -517,6 +517,20 @@ struct eth_dev_ops {/**< Test if a port supports specific mempool ops */ }; +/** +* @internal +* Get basic stats for ethdev +*/ +int __rte_experimental +rte_eth_basic_stats_count (struct rte_eth_dev *dev); + +int __rte_experimental +rte_eth_basic_stats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names); + +int __rte_experimental +rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats); +/**
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_core.h struct eth_dev_ops { · line 536
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_core.h +0
-0* @internal * Structure used to hold information about the callbacks to be called for a It conflicts with
__rte_experimenalplacing patch which is on the mailing list.
Also I've expected to see these functions inrte_ethdev_driver.hto avoid inclusion inrte_ethdev.h. As I understand these functions are forrte_ethdevand drivers only.
Yes. Will change in V3
PATCH v2 2/2 failsafe: implement xstats
In reply to Stephen HemmingerAdd support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 130 ++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+)
drivers/net/failsafe/failsafe_ops.c +130 -0
@@ -789,6 +789,133 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), + xstats_names + count, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1360,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 2/2] failsafe: implement xstats
Hello Stephen,
Quoted 54 lines · Stephen Hemminger
Add support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/failsafe/failsafe_ops.c | 130 ++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+)drivers/net/failsafe/failsafe_ops.c +37
-0@@ -789,6 +789,133 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r;
drivers/net/failsafe/failsafe_ops.c fs_stats_reset(struct rte_eth_dev *dev) · line 838
Quoted 10 lines
drivers/net/failsafe/failsafe_ops.c +10
-0+ +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r = rte_eth_xstats_get_names(PORT_ID(sdev), + xstats_names + count,
sub_names here?
Or do you want to point our the relationship between + count on the array and - count on the array length? If so that makes sense.
drivers/net/failsafe/failsafe_ops.c fs_stats_reset(struct rte_eth_dev *dev) · line 847
Quoted 9 lines
drivers/net/failsafe/failsafe_ops.c +9
-0+ limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { + snprintf(tmp, sizeof(tmp), "sub%u_%s",
Prefixing is a good idea, maybe it would be better with an '_' between the sub device name and the stat name?
The rest of the implementation seems solid, thanks.
You need to update the feature matrix for fail-safe however.
Regards,
Signature · 2 lines
Gaëtan Rivet 6WIND
v2 cover *failsafe: add xstats
In reply to Stephen HemmingerA useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v2
move generic xstats helpers to rte_ethdev_driver.h change prefix on subdevice stats to sub0_XXXX
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 4 files changed, 211 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 ethdev: expose basic xstats for driver use
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 +++---- lib/librte_ethdev/rte_ethdev_driver.h | 65 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 ++ 3 files changed, 76 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_driver.h +65 -0
71 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -239,6 +239,9 @@ DPDK_19.05 { EXPERIMENTAL { global: + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; rte_eth_devargs_parse; rte_eth_dev_create; rte_eth_dev_destroy;
Signature · 1 line
2.20.1
PATCH v2 2/2 failsafe: implement xstats
In reply to Stephen HemmingerAdd support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 135 ++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
drivers/net/failsafe/failsafe_ops.c +135 -0
@@ -789,6 +789,138 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +/* +* Count how many xstats in total +* Include basic stats for failsafe device +* plus xstats for each sub-device present. +*/ +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +/* Caller only cares about count */ +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1365,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 0/2] *failsafe: add xstats
In reply to Stephen HemmingerQuoted 4 lines · Stephen Hemminger
A useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Quoted 8 lines
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v2
move generic xstats helpers torte_ethdev_driver.hchange prefix on subdevice stats tosub0_XXXX
For the series:
Quoted 13 lines
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
failsafe: implement xstatsdrivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 4 files changed, 211 insertions(+), 9 deletions(-)Signature · 1 line
2.20.1
Signature · 2 lines
Gaëtan Rivet 6WIND
v3 cover failsafe: add xstats
In reply to Stephen HemmingerA useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v3 - rebase to 19.08
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
net/failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 24 ++++ 4 files changed, 232 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
PATCH v3 1/2 ethdev: expose basic xstats for driver use
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 +++---- lib/librte_ethdev/rte_ethdev_driver.h | 65 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 24 +++++++++ 3 files changed, 97 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_driver.h +65 -0
71 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +24 -0
@@ -240,6 +240,25 @@ EXPERIMENTAL { global: # added in 17.11 + rte_eth_devargs_parse; + rte_eth_dev_create; + rte_eth_dev_destroy; + rte_eth_dev_get_module_eeprom; + rte_eth_dev_get_module_info; + rte_eth_dev_is_removed; + rte_eth_dev_owner_delete; + rte_eth_dev_owner_get; + rte_eth_dev_owner_new; + rte_eth_dev_owner_set; + rte_eth_dev_owner_unset; + rte_eth_dev_rx_intr_ctl_q_get_fd; + rte_eth_find_next_of; + rte_eth_find_next_sibling; + rte_eth_read_clock; + rte_eth_switch_domain_alloc; + rte_eth_switch_domain_free; + rte_flow_conv; + rte_flow_expand_rss; rte_mtr_capabilities_get; rte_mtr_create; rte_mtr_destroy;
@@ -283,4 +302,9 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; };
Signature · 1 line
2.20.1
PATCH v3 2/2 net/failsafe: implement xstats
In reply to Stephen HemmingerAdd support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 135 ++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
drivers/net/failsafe/failsafe_ops.c +135 -0
@@ -789,6 +789,138 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +/* +* Count how many xstats in total +* Include basic stats for failsafe device +* plus xstats for each sub-device present. +*/ +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +/* Caller only cares about count */ +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1365,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.20.1
v4 cover failsafe: add xstats
In reply to Stephen HemmingerA useful feature of netvsc PMD is the ability to see how many packets were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v4 - rebase to 19.11-rc
v3 - rebase to 19.08
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
net/failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 24 ++++ 4 files changed, 232 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 ethdev: expose basic xstats for driver use
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 +++---- lib/librte_ethdev/rte_ethdev_driver.h | 65 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 24 +++++++++ 3 files changed, 97 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_driver.h +65 -0
71 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +24 -0
@@ -240,6 +240,25 @@ EXPERIMENTAL { global: # added in 17.11 + rte_eth_devargs_parse; + rte_eth_dev_create; + rte_eth_dev_destroy; + rte_eth_dev_get_module_eeprom; + rte_eth_dev_get_module_info; + rte_eth_dev_is_removed; + rte_eth_dev_owner_delete; + rte_eth_dev_owner_get; + rte_eth_dev_owner_new; + rte_eth_dev_owner_set; + rte_eth_dev_owner_unset; + rte_eth_dev_rx_intr_ctl_q_get_fd; + rte_eth_find_next_of; + rte_eth_find_next_sibling; + rte_eth_read_clock; + rte_eth_switch_domain_alloc; + rte_eth_switch_domain_free; + rte_flow_conv; + rte_flow_expand_rss; rte_mtr_capabilities_get; rte_mtr_create; rte_mtr_destroy;
@@ -283,4 +302,9 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; };
Signature · 1 line
2.17.1
PATCH 2/2 net/failsafe: implement xstats
In reply to Stephen HemmingerAdd support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 135 ++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
drivers/net/failsafe/failsafe_ops.c +135 -0
@@ -789,6 +789,138 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +/* +* Count how many xstats in total +* Include basic stats for failsafe device +* plus xstats for each sub-device present. +*/ +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +/* Caller only cares about count */ +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1365,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.17.1
v5 cover failsafe: add xstats
In reply to Stephen HemmingerA useful feature of netvsc PMD is the ability to see how many packets
were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.
Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v5 - fix ethdev map file
v4 - rebase to 19.11
v3 - rebase to 19.08
Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
net/failsafe: implement xstats
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 + 4 files changed, 213 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.1
PATCH v5 1/2 ethdev: expose basic xstats for driver use
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
--- lib/librte_ethdev/rte_ethdev.c | 17 +++---- lib/librte_ethdev/rte_ethdev_driver.h | 65 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 ++ 3 files changed, 78 insertions(+), 9 deletions(-)
lib/librte_ethdev/rte_ethdev.c +8 -9
@@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } -static inline int -get_xstats_basic_count (struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count (struct rte_eth_dev *dev) {uint16_t nb_rxqs, nb_txqs;int count;
@@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count =0 ; - count +=get_xstats_basic_count (dev); + count +=rte_eth_basic_stats_count (dev);return count; }
@@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, }/* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names) {
@@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev); ret =get_xstats_count (port_id);if (ret <0 )return ret;
@@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id,return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get (uint16_t port_id,struct rte_eth_xstat *xstats) {struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t )ret;struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count =get_xstats_basic_count (dev); + basic_count =rte_eth_basic_stats_count (dev);/* Return max number of stats if no ids given */ if (!ids) {
@@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,return -EINVAL ;if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { -unsigned int basic_count =get_xstats_basic_count (dev); +unsigned int basic_count =rte_eth_basic_stats_count (dev);uint64_t ids_copy[size];for (i =0 ; i < size; i++) {
lib/librte_ethdev/rte_ethdev_driver.h +65 -0
71 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +5 -0
@@ -283,4 +283,9 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: expose basic xstats for driver use
Quoted 6 lines · Stephen Hemminger
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Gaetan Rivet <[email protected]>
Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0@@ -208,6 +208,71 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev,#endif
lib/librte_ethdev/rte_ethdev_driver.h rte_eth_linkstatus_get(const struct rte_eth_dev *dev, · line 218
Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +8
-0} +/** +* @internal +* Get basic stats part of xstats for an ethernet device. +* +* @param dev +* Pointer to struct rte_eth_dev. +*/ +__rte_experimental
Does it make sense to mark internal API as experimental? I thought that @internal is not a part of API/ABI.
[snip]
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: expose basic xstats for driver use
Quoted 18 lines · On Thu, 26 Sep 2019 15:46:52 +0300 Andrew Rybchenko…
Quoted 6 lines · Stephen Hemminger
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Gaetan Rivet <[email protected]>Acked-by Andrew Rybchenko <[email protected]>Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0@@ -208,6 +208,71 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev,#endif }
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_driver.h rte_eth_linkstatus_get(const struct rte_eth_dev *dev, · line 218
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8
-0+/** +* @internal +* Get basic stats part of xstats for an ethernet device. +* +* @param dev +* Pointer to struct rte_eth_dev. +*/ +__rte_experimentalDoes it make sense to mark internal API as experimental? I thought that @internal is not a part of API/ABI.
agree, but checkpatch doesn't understand @internal tag.
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: expose basic xstats for driver use
In reply to Andrew RybchenkoQuoted 18 lines · On Thu, 26 Sep 2019 15:46:52 +0300 Andrew Rybchenko…
Quoted 6 lines · Stephen Hemminger
Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Gaetan Rivet <[email protected]>Acked-by Andrew Rybchenko <[email protected]>Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0@@ -208,6 +208,71 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev,#endif }
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_driver.h rte_eth_linkstatus_get(const struct rte_eth_dev *dev, · line 218
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_driver.h +8
-0+/** +* @internal +* Get basic stats part of xstats for an ethernet device. +* +* @param dev +* Pointer to struct rte_eth_dev. +*/ +__rte_experimentalDoes it make sense to mark internal API as experimental? I thought that @internal is not a part of API/ABI.
Checkpatch picks on it
PATCH v5 2/2 net/failsafe: implement xstats
In reply to Stephen HemmingerAdd support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
--- drivers/net/failsafe/failsafe_ops.c | 135 ++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
drivers/net/failsafe/failsafe_ops.c +135 -0
@@ -789,6 +789,138 @@ fs_stats_reset(struct rte_eth_dev *dev)fs_unlock (dev,0 ); } +/* +* Count how many xstats in total +* Include basic stats for failsafe device +* plus xstats for each sub-device present. +*/ +static int +fs_xstats_count (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; +int count; + + count =rte_eth_basic_stats_count (dev); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + count +=rte_eth_xstats_get_names (PORT_ID (sdev),NULL ,0 ); + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +/* Caller only cares about count */ +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ; + + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) { +snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +} + +static int +fs_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats, +unsigned int n) +{ +unsigned int nstats, j, count, scount; +struct sub_device *sdev; +uint8_t i; +int ret; + + nstats =fs_xstats_count (dev); +if (n < nstats || xstats ==NULL ) +return nstats; + + ret =rte_eth_basic_stats_get (dev->data->port_id, xstats); +if (ret <0 ) +return ret; + + count = ret; +for (j =0 ; j < count; j++) + xstats[j].id = j; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { + ret =rte_eth_xstats_get (PORT_ID (sdev), + xstats + count, + n > count ? n - count :0 ); +if (ret <0 ) { +fs_unlock (dev,0 ); +return ret; + } + scount = ret; + +/* add offset to id's from sub-device */ +for (j =0 ; j < scount; j++) + xstats[count + j].id += count; + + count += scount; + } +fs_unlock (dev,0 ); + +return count; +} + +static void +fs_xstats_reset (struct rte_eth_dev *dev) +{ +struct sub_device *sdev; +uint8_t i; + +rte_eth_stats_reset (dev->data->port_id); + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +rte_eth_xstats_reset (PORT_ID (sdev)); + } +fs_unlock (dev,0 ); +} +static void fs_dev_merge_desc_lim (struct rte_eth_desc_lim *to,const struct rte_eth_desc_lim *from)
@@ -1233,6 +1365,9 @@ const struct eth_dev_ops failsafe_ops = { .link_update = fs_link_update, .stats_get = fs_stats_get, .stats_reset = fs_stats_reset, + .xstats_get = fs_xstats_get, + .xstats_get_names = fs_xstats_get_names, + .xstats_reset = fs_xstats_reset, .dev_infos_get = fs_dev_infos_get, .dev_supported_ptypes_get = fs_dev_supported_ptypes_get, .mtu_set = fs_mtu_set,
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v5 2/2] net/failsafe: implement xstats
Quoted 3 lines · Stephen Hemminger
Add support for extended statistics in failsafe driver. Reports basic statistics for the failsafe driver, and detailed statistics for each sub device.
+1, but doesn't need to pull basic stats to the xstats in the PMD level, that part is already done by xstats API [1],
so 'fs_xstats_get.*()' functions return only sub-device basic stats is good enough which won't require the new 'rte_eth_basic_stats_.*()' APIs.
Current implementation cause basic stats part duplicated for failsafe device.
[1]rte_eth_xstats_get_names
cnt_used_entries = rte_eth_basic_stats_get_names(dev, xstats_names) cnt_driver_entries = (*dev->dev_ops->xstats_get_names)(...) cnt_used_entries += cnt_driver_entries
return cnt_used_entries;
btw, while testing this I have observed an always reproducible seg fault by failsafe on testpmd quit [2], but didn't checked more, @Gaetan can you please check this when possible?
[2]
Shutting down port 1...
Closing ports...
Done
Segmentation fault (core dumped)
With command:
testpmd -w 0:0.0 --vdev net_null0 --vdev
"net_failsafe0,dev(86:00.1),dev(86:00.3)" -- -i
Quoted 3 lines
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Gaetan Rivet <[email protected]>
<...>
Quoted 27 lines
drivers/net/failsafe/failsafe_ops.c +27
-0+static int +fs_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names, +unsigned int limit) +{ +struct sub_device *sdev; +unsigned int count; +char tmp[RTE_ETH_XSTATS_NAME_SIZE ]; +uint8_t i; +int r; + +/* Caller only cares about count */ +if (!xstats_names) +return fs_xstats_count (dev); + + r =rte_eth_basic_stats_get_names (dev, xstats_names); +if (r <0 ) +return r; + + count = r; + +fs_lock (dev,0 ); + FOREACH_SUBDEV(sdev, i, dev) { +struct rte_eth_xstat_name *sub_names = xstats_names + count; + +if (count >= limit) +break ;
drivers/net/failsafe/failsafe_ops.c fs_stats_reset(struct rte_eth_dev *dev) · line 851
Quoted 10 lines
drivers/net/failsafe/failsafe_ops.c +10
-0+ + r =rte_eth_xstats_get_names (PORT_ID (sdev), sub_names, + limit - count); +if (r <0 ) { +fs_unlock (dev,0 ); +return r; + } + +/* add sub_ prefix to names */ +for (i =0 ; i < r; i++) {
'i' is used in outer loop as well
thanks to 'C' to let us do these kind of things without any kind of warning. Also it shows maintainer acked without testing :(
Quoted 12 lines
drivers/net/failsafe/failsafe_ops.c +12
-0+snprintf (tmp,sizeof (tmp),"sub%u_%s" , + i, sub_names[i].name); +memcpy (sub_names[i].name, tmp, +RTE_ETH_XSTATS_NAME_SIZE ); + } + + count += r; + } +fs_unlock (dev,0 ); + +return count; +}
<...>
Quoted 17 lines · On Thu, 19 Sep 2019 15:17:27 +0200 Stephen Hemminger…
A useful feature of netvsc PMD is the ability to see how many packets
were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v5 - fix ethdev map file
v4 - rebase to 19.11
v3 - rebase to 19.08Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
net/failsafe: implement xstats
Quoted 6 lines
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 + 4 files changed, 213 insertions(+), 9 deletions(-)
Why are these patches still not merged?
Quoted 20 lines · Stephen Hemminger
Quoted 17 lines · On Thu, 19 Sep 2019 15:17:27 +0200 Stephen Hemminger…
A useful feature of netvsc PMD is the ability to see how many packets
were processed through the VF device. This patch set adds a similar (but more limited) capability to failsafe driver.Since failsafe doesn't have top level xstats, this set uses the generic xstats that exist already as a base then adds the sub-device xstats to that.
v5 - fix ethdev map file
v4 - rebase to 19.11
v3 - rebase to 19.08Stephen Hemminger (2):
ethdev: expose basic xstats for driver use
net/failsafe: implement xstats
Quoted 9 lines
Quoted 6 lines
drivers/net/failsafe/failsafe_ops.c | 135 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 17 ++- lib/librte_ethdev/rte_ethdev_driver.h | 65 +++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 + 4 files changed, 213 insertions(+), 9 deletions(-)Why are these patches still not merged?
Because patches are not reviewed yet, specially ethdev one.