From: Igor Romanov Date: Tue, 10 Sep 2019 08:52:15 +0000 (+0100) Subject: ethdev: change MAC address get function to return int X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1cde5e0acaface5862cb6699c4cee399b7a5280f;p=dpdk.git ethdev: change MAC address get function to return int Change rte_eth_macaddr_get() return value from void to int and return negative errno values in case of error conditions. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 38a6e5348e..743f97fbb7 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -91,7 +91,6 @@ Deprecation Notices - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable`` - ``rte_eth_dev_stop`` - ``rte_eth_dev_close`` - - ``rte_eth_macaddr_get`` - ``rte_eth_dev_owner_delete`` * ethdev: New offload flags ``DEV_RX_OFFLOAD_RSS_HASH`` and diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 2c79210fc2..1bff8721f7 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -137,6 +137,9 @@ API Changes return value from ``void`` to ``int`` to provide a way to report various error conditions. +* ethdev: changed ``rte_eth_macaddr_get`` return value from ``void`` to + ``int`` to provide a way to report various error conditions. + ABI Changes ----------- diff --git a/doc/guides/sample_app_ug/flow_classify.rst b/doc/guides/sample_app_ug/flow_classify.rst index 7c2b6dcf83..bc234b50a7 100644 --- a/doc/guides/sample_app_ug/flow_classify.rst +++ b/doc/guides/sample_app_ug/flow_classify.rst @@ -306,7 +306,9 @@ Forwarding application is shown below: return retval; /* Display the port MAC address. */ - rte_eth_macaddr_get(port, &addr); + retval = rte_eth_macaddr_get(port, &addr); + if (retval < 0) + return retval; printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n", port, diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 2f5338cedf..56875bb369 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2671,14 +2671,16 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, return j; } -void +int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr) { struct rte_eth_dev *dev; - RTE_ETH_VALID_PORTID_OR_RET(port_id); + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; rte_ether_addr_copy(&dev->data->mac_addrs[0], mac_addr); + + return 0; } diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index b55f012cb2..d3f4f25730 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2351,8 +2351,11 @@ int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id, * @param mac_addr * A pointer to a structure of type *ether_addr* to be filled with * the Ethernet address of the Ethernet device. + * @return + * - (0) if successful + * - (-ENODEV) if *port_id* invalid. */ -void rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr); +int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr); /** * Retrieve the contextual information of an Ethernet device.