DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] rte_ethdev: make tables const
Date: Thu,  9 Apr 2015 14:29:41 -0700	[thread overview]
Message-ID: <1428614982-14135-4-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1428614982-14135-1-git-send-email-stephen@networkplumber.org>

The statistics tables and null mac address should be immutable.
Fix up get_addr routines to accept const args.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_ether/rte_ethdev.c | 44 +++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 56e22ea..416e778 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -119,34 +119,34 @@ struct rte_eth_xstats_name_off {
 	unsigned offset;
 };
 
-static struct rte_eth_xstats_name_off rte_stats_strings[] = {
-	 {"rx_packets", offsetof(struct rte_eth_stats, ipackets)},
-	 {"tx_packets", offsetof(struct rte_eth_stats, opackets)},
-	 {"rx_bytes", offsetof(struct rte_eth_stats, ibytes)},
-	 {"tx_bytes", offsetof(struct rte_eth_stats, obytes)},
-	 {"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
-	 {"rx_missed_errors", offsetof(struct rte_eth_stats, imissed)},
-	 {"rx_crc_errors", offsetof(struct rte_eth_stats, ibadcrc)},
-	 {"rx_bad_length_errors", offsetof(struct rte_eth_stats, ibadlen)},
-	 {"rx_errors", offsetof(struct rte_eth_stats, ierrors)},
-	 {"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)},
-	 {"fdir_match", offsetof(struct rte_eth_stats, fdirmatch)},
-	 {"fdir_miss", offsetof(struct rte_eth_stats, fdirmiss)},
-	 {"tx_flow_control_xon", offsetof(struct rte_eth_stats, tx_pause_xon)},
-	 {"rx_flow_control_xon", offsetof(struct rte_eth_stats, rx_pause_xon)},
-	 {"tx_flow_control_xoff", offsetof(struct rte_eth_stats, tx_pause_xoff)},
-	 {"rx_flow_control_xoff", offsetof(struct rte_eth_stats, rx_pause_xoff)},
+static const struct rte_eth_xstats_name_off rte_stats_strings[] = {
+	{"rx_packets", offsetof(struct rte_eth_stats, ipackets)},
+	{"tx_packets", offsetof(struct rte_eth_stats, opackets)},
+	{"rx_bytes", offsetof(struct rte_eth_stats, ibytes)},
+	{"tx_bytes", offsetof(struct rte_eth_stats, obytes)},
+	{"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
+	{"rx_missed_errors", offsetof(struct rte_eth_stats, imissed)},
+	{"rx_crc_errors", offsetof(struct rte_eth_stats, ibadcrc)},
+	{"rx_bad_length_errors", offsetof(struct rte_eth_stats, ibadlen)},
+	{"rx_errors", offsetof(struct rte_eth_stats, ierrors)},
+	{"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)},
+	{"fdir_match", offsetof(struct rte_eth_stats, fdirmatch)},
+	{"fdir_miss", offsetof(struct rte_eth_stats, fdirmiss)},
+	{"tx_flow_control_xon", offsetof(struct rte_eth_stats, tx_pause_xon)},
+	{"rx_flow_control_xon", offsetof(struct rte_eth_stats, rx_pause_xon)},
+	{"tx_flow_control_xoff", offsetof(struct rte_eth_stats, tx_pause_xoff)},
+	{"rx_flow_control_xoff", offsetof(struct rte_eth_stats, rx_pause_xoff)},
 };
 #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0]))
 
-static struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = {
+static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = {
 	{"rx_packets", offsetof(struct rte_eth_stats, q_ipackets)},
 	{"rx_bytes", offsetof(struct rte_eth_stats, q_ibytes)},
 };
 #define RTE_NB_RXQ_STATS (sizeof(rte_rxq_stats_strings) /	\
 		sizeof(rte_rxq_stats_strings[0]))
 
-static struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
+static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
 	{"tx_packets", offsetof(struct rte_eth_stats, q_opackets)},
 	{"tx_bytes", offsetof(struct rte_eth_stats, q_obytes)},
 	{"tx_errors", offsetof(struct rte_eth_stats, q_errors)},
@@ -2651,7 +2651,7 @@ rte_eth_led_off(uint8_t port_id)
  * an empty spot.
  */
 static int
-get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
+get_mac_addr_index(uint8_t port_id, const struct ether_addr *addr)
 {
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
@@ -2666,7 +2666,7 @@ get_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
 	return -1;
 }
 
-static struct ether_addr null_mac_addr = {{0, 0, 0, 0, 0, 0}};
+static const struct ether_addr null_mac_addr;
 
 int
 rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
@@ -2792,7 +2792,7 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
  * an empty spot.
  */
 static int
-get_hash_mac_addr_index(uint8_t port_id, struct ether_addr *addr)
+get_hash_mac_addr_index(uint8_t port_id, const struct ether_addr *addr)
 {
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-- 
2.1.4

  parent reply	other threads:[~2015-04-09 21:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 21:29 [dpdk-dev] [PATCH 0/4] rte_ethdev: cleanups Stephen Hemminger
2015-04-09 21:29 ` [dpdk-dev] [PATCH 1/4] rte_ethdev: remove extra inline Stephen Hemminger
2015-04-15  9:52   ` Bruce Richardson
2015-04-09 21:29 ` [dpdk-dev] [PATCH 2/4] rte_ethdev: whitespace cleanup Stephen Hemminger
2015-04-15  9:53   ` Bruce Richardson
2015-04-09 21:29 ` Stephen Hemminger [this message]
2015-04-15  9:54   ` [dpdk-dev] [PATCH 3/4] rte_ethdev: make tables const Bruce Richardson
2015-04-09 21:29 ` [dpdk-dev] [PATCH 4/4] rte_ethdev: remove unnecessary paren on return Stephen Hemminger
2015-04-15  9:56   ` Bruce Richardson
2015-04-20 17:52 ` [dpdk-dev] [PATCH 0/4] rte_ethdev: cleanups Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428614982-14135-4-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).