patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, stable@dpdk.org,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-stable] [PATCH v1 2/9] net/bnxt: fix to alloc LED config info
Date: Fri, 15 May 2020 11:45:35 -0700	[thread overview]
Message-ID: <20200515184542.89318-3-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200515184542.89318-1-ajit.khaparde@broadcom.com>

Dynamically allocate bnxt_led_cfg.
This helps reduces memory footprint of struct bnxt.

Fixes: bb81e07323b ("net/bnxt: support LED on/off")
Cc: stable@dpdk.org

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  4 ++--
 drivers/net/bnxt/bnxt_ethdev.c | 23 +++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   | 14 +++++++-------
 3 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index bf5b39cd3..f4b39b345 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -147,6 +147,7 @@
 #define BNXT_NUM_CMPL_DMA_AGGR_DURING_INT	12
 
 struct bnxt_led_info {
+	uint8_t	     num_leds;
 	uint8_t      led_id;
 	uint8_t      led_type;
 	uint8_t      led_group_id;
@@ -686,8 +687,7 @@ struct bnxt {
 	uint32_t		fw_ver;
 	uint32_t		hwrm_spec_code;
 
-	struct bnxt_led_info	leds[BNXT_MAX_LED];
-	uint8_t			num_leds;
+	struct bnxt_led_info	*leds;
 	struct bnxt_ptp_cfg     *ptp_cfg;
 	uint16_t		vf_resv_strategy;
 	struct bnxt_ctx_mem_info        *ctx;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 2ba9d6bad..3bd30dfa1 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -191,6 +191,12 @@ static uint16_t  bnxt_rss_hash_tbl_size(const struct bnxt *bp)
 	return bnxt_rss_ctxts(bp) * BNXT_RSS_ENTRIES_PER_CTX_THOR;
 }
 
+static void bnxt_free_leds_info(struct bnxt *bp)
+{
+	rte_free(bp->leds);
+	bp->leds = NULL;
+}
+
 static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
 {
 	bnxt_free_filter_mem(bp);
@@ -213,6 +219,17 @@ static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
 	bp->grp_info = NULL;
 }
 
+static int bnxt_alloc_leds_info(struct bnxt *bp)
+{
+	bp->leds = rte_zmalloc("bnxt_leds",
+			       BNXT_MAX_LED * sizeof(struct bnxt_led_info),
+			       0);
+	if (bp->leds == NULL)
+		return -ENOMEM;
+
+	return 0;
+}
+
 static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig)
 {
 	int rc;
@@ -1216,6 +1233,8 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 
 	bnxt_uninit_resources(bp, false);
 
+	bnxt_free_leds_info(bp);
+
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
@@ -5359,6 +5378,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 			    "Failed to allocate hwrm resource rc: %x\n", rc);
 		goto error_free;
 	}
+	rc = bnxt_alloc_leds_info(bp);
+	if (rc)
+		goto error_free;
+
 	rc = bnxt_init_resources(bp, false);
 	if (rc)
 		goto error_free;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index d80d67a2d..148000934 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3900,17 +3900,17 @@ int bnxt_hwrm_port_led_qcaps(struct bnxt *bp)
 	if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) {
 		unsigned int i;
 
-		bp->num_leds = resp->num_leds;
+		bp->leds->num_leds = resp->num_leds;
 		memcpy(bp->leds, &resp->led0_id,
-			sizeof(bp->leds[0]) * bp->num_leds);
-		for (i = 0; i < bp->num_leds; i++) {
+			sizeof(bp->leds[0]) * bp->leds->num_leds);
+		for (i = 0; i < bp->leds->num_leds; i++) {
 			struct bnxt_led_info *led = &bp->leds[i];
 
 			uint16_t caps = led->led_state_caps;
 
 			if (!led->led_group_id ||
 				!BNXT_LED_ALT_BLINK_CAP(caps)) {
-				bp->num_leds = 0;
+				bp->leds->num_leds = 0;
 				break;
 			}
 		}
@@ -3930,7 +3930,7 @@ int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)
 	uint16_t duration = 0;
 	int rc, i;
 
-	if (!bp->num_leds || BNXT_VF(bp))
+	if (!bp->leds->num_leds || BNXT_VF(bp))
 		return -EOPNOTSUPP;
 
 	HWRM_PREP(&req, HWRM_PORT_LED_CFG, BNXT_USE_CHIMP_MB);
@@ -3940,9 +3940,9 @@ int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on)
 		duration = rte_cpu_to_le_16(500);
 	}
 	req.port_id = bp->pf.port_id;
-	req.num_leds = bp->num_leds;
+	req.num_leds = bp->leds->num_leds;
 	led_cfg = (struct bnxt_led_cfg *)&req.led0_id;
-	for (i = 0; i < bp->num_leds; i++, led_cfg++) {
+	for (i = 0; i < bp->leds->num_leds; i++, led_cfg++) {
 		req.enables |= BNXT_LED_DFLT_ENABLES(i);
 		led_cfg->led_id = bp->leds[i].led_id;
 		led_cfg->led_state = led_state;
-- 
2.21.1 (Apple Git-122.3)


  parent reply	other threads:[~2020-05-15 18:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200515184542.89318-1-ajit.khaparde@broadcom.com>
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 1/9] net/bnxt: fix error log for command timeout Ajit Khaparde
2020-05-15 18:45 ` Ajit Khaparde [this message]
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 3/9] net/bnxt: fix to alloc COS queue info dynamically Ajit Khaparde
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 5/9] net/bnxt: fix to alloc link info struct Ajit Khaparde
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 6/9] net/bnxt: fix to alloc PF info structure Ajit Khaparde
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 7/9] net/bnxt: fix to use RSS config from eth dev struct Ajit Khaparde
2020-05-15 18:45 ` [dpdk-stable] [PATCH v1 8/9] net/bnxt: fix to remove unneeded structure variable Ajit Khaparde

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=20200515184542.89318-3-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=stable@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).