All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Chan" <mchan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, barak@broadcom.com, eilong@broadcom.com
Subject: [PATCH net-next 3/4] bnx2x: support classification config query
Date: Mon, 5 Dec 2011 21:44:47 -0800	[thread overview]
Message-ID: <1323150288-28153-3-git-send-email-mchan@broadcom.com> (raw)
In-Reply-To: <1323150288-28153-2-git-send-email-mchan@broadcom.com>

From: Ariel Elior <ariele@broadcom.com>

To support copying MAC addresses to firmware info structure in the proper
format.

Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c |   39 ++++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h |   17 ++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index a34362e..da377d1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -30,6 +30,8 @@
 
 #define BNX2X_MAX_EMUL_MULTI		16
 
+#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
+
 /**** Exe Queue interfaces ****/
 
 /**
@@ -441,6 +443,42 @@ static bool bnx2x_put_credit_vlan_mac(struct bnx2x_vlan_mac_obj *o)
 	return true;
 }
 
+static int bnx2x_get_n_elements(struct bnx2x *bp,
+			 struct bnx2x_vlan_mac_obj *o,
+			 int n,
+			 u8 *buf)
+{
+	struct bnx2x_vlan_mac_registry_elem *pos;
+	u8 *next = buf;
+	int counter = 0;
+
+	/* traverse list */
+	list_for_each_entry(pos, &o->head, link)
+	{
+		if ((counter < n)) {
+
+			/* place leading zeroes in buffer */
+			memset(next, 0, MAC_LEADING_ZERO_CNT);
+
+			/* place mac after leading zeroes*/
+			memcpy(next + MAC_LEADING_ZERO_CNT,
+				  pos->u.mac.mac, ETH_ALEN);
+
+			/* calculate address of next element and
+			 * advance counter
+			 */
+			counter++;
+			next = buf + counter * ALIGN(ETH_ALEN,
+							   sizeof(u32));
+
+			DP(BNX2X_MSG_SP, "copied element number "
+				   "%d to address %p element was "
+				   "%pM\n", counter, next, pos->u.mac.mac);
+		}
+	}
+	return counter * ETH_ALEN;
+}
+
 /* check_add() callbacks */
 static int bnx2x_check_mac_add(struct bnx2x_vlan_mac_obj *o,
 			       union bnx2x_classification_ramrod_data *data)
@@ -1886,6 +1924,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
 		mac_obj->check_move        = bnx2x_check_move;
 		mac_obj->ramrod_cmd        =
 			RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES;
+		mac_obj->get_n_elements    = bnx2x_get_n_elements;
 
 		/* Exe Queue */
 		bnx2x_exe_queue_init(bp,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 9a517c2..bf898fb 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -286,6 +286,23 @@ struct bnx2x_vlan_mac_obj {
 	int				ramrod_cmd;
 
 	/**
+	 * copy first n elements onto preallocated buffer
+	 *
+	 * @param n number of elements to get
+	 * @param buf buffer preallocated by caller into which elements
+	 *            will be copied. Note elements are 4-byte aligned
+	 *            so buffer size must be able to accomodate the
+	 *            aligned elements.
+	 *
+	 * @return number of copied bytes
+	 *  */
+
+	int (*get_n_elements)(struct bnx2x *bp,
+			 struct bnx2x_vlan_mac_obj *o,
+			 int n,
+			 u8 *buf);
+
+	/**
 	 * Checks if ADD-ramrod with the given params may be performed.
 	 *
 	 * @return zero if the element may be added
-- 
1.7.1

  reply	other threads:[~2011-12-06  5:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06  5:44 [PATCH net-next 1/4] bnx2x: add PFC statistics Michael Chan
2011-12-06  5:44 ` [PATCH net-next 2/4] bnx2x: add fcoe statistics Michael Chan
2011-12-06  5:44   ` Michael Chan [this message]
2011-12-06  5:44     ` [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request Michael Chan
2011-12-06  5:56       ` Joe Perches
2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
2011-12-06  5:57       ` Michael Chan
2011-12-06  5:59       ` Joe Perches

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=1323150288-28153-3-git-send-email-mchan@broadcom.com \
    --to=mchan@broadcom.com \
    --cc=barak@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=eilong@broadcom.com \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.