All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-net-drivers@solarflare.com>,
	Andrew Jackson <ajackson@solarflare.com>,
	Richard Cochran <richardcochran@gmail.com>
Subject: [PATCH net-next 5/7] sfc: Support variable-length response to MCDI GET_BOARD_CFG
Date: Wed, 18 Jul 2012 19:21:57 +0100	[thread overview]
Message-ID: <1342635717.2617.57.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <1342635392.2617.52.camel@bwh-desktop.uk.solarflarecom.com>

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/ethernet/sfc/mcdi.c |   18 +++++++++++++-----
 drivers/net/ethernet/sfc/mtd.c  |    3 ++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index 294df4b..9f74ab6 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -660,8 +660,8 @@ fail:
 int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
 			   u16 *fw_subtype_list, u32 *capabilities)
 {
-	uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN];
-	size_t outlen;
+	uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX];
+	size_t outlen, src_size, dst_size;
 	int port_num = efx_port_num(efx);
 	int offset;
 	int rc;
@@ -683,11 +683,19 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
 		: MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST;
 	if (mac_address)
 		memcpy(mac_address, outbuf + offset, ETH_ALEN);
-	if (fw_subtype_list)
+	if (fw_subtype_list) {
+		/* Truncate or zero-pad as necessary */
+		src_size = (outlen -
+			    MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST);
+		dst_size = (MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM *
+			    sizeof(*fw_subtype_list));
 		memcpy(fw_subtype_list,
 		       outbuf + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST,
-		       MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM *
-		       sizeof(fw_subtype_list[0]));
+		       min(src_size, dst_size));
+		if (dst_size < src_size)
+			memset(fw_subtype_list + src_size, 0,
+			       dst_size - src_size);
+	}
 	if (capabilities) {
 		if (port_num)
 			*capabilities = MCDI_DWORD(outbuf,
diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c
index 7581483..8f4604d 100644
--- a/drivers/net/ethernet/sfc/mtd.c
+++ b/drivers/net/ethernet/sfc/mtd.c
@@ -627,7 +627,8 @@ static int siena_mtd_get_fw_subtypes(struct efx_nic *efx,
 				     struct efx_mtd *efx_mtd)
 {
 	struct efx_mtd_partition *part;
-	uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM];
+	uint16_t fw_subtype_list[
+		MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM];
 	int rc;
 
 	rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL);
-- 
1.7.7.6



-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  parent reply	other threads:[~2012-07-18 18:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 18:16 pull request: sfc-next 2012-07-18 Ben Hutchings
2012-07-18 18:19 ` [PATCH net-next 1/7] sfc: Add explicit RX queue flag to channel Ben Hutchings
2012-07-18 18:20 ` [PATCH net-next 2/7] sfc: Add channel specific receive_skb handler and post_remove callback Ben Hutchings
2012-07-18 18:32   ` David Miller
2012-07-18 18:42     ` Ben Hutchings
2012-07-18 18:43       ` David Miller
2012-07-18 18:20 ` [PATCH net-next 3/7] sfc: Allow efx_mcdi_rpc to be called in two parts Ben Hutchings
2012-07-18 18:21 ` [PATCH net-next 4/7] sfc: Add support for IEEE-1588 PTP Ben Hutchings
2012-07-19 14:25   ` Richard Cochran
2012-07-19 14:37     ` Ben Hutchings
2012-07-19 16:05       ` Andrew Jackson
2012-07-20  6:11         ` Richard Cochran
2012-07-19 15:29     ` Stuart Hodgson
2012-07-19 15:43       ` David Miller
2012-07-19 15:50       ` Ben Hutchings
2012-07-20  7:37         ` Richard Cochran
2012-07-20  6:31       ` Richard Cochran
2012-07-20  9:15         ` Stuart Hodgson
2012-07-20 15:30           ` Richard Cochran
2012-07-30 10:03             ` Stuart Hodgson
2012-07-18 18:21 ` Ben Hutchings [this message]
2012-07-18 18:22 ` [PATCH net-next 6/7] sfc: Expose FPGA bitfile partition through MTD Ben Hutchings
2012-07-18 18:22 ` [PATCH net-next 7/7] sfc: Bump version to 3.2 Ben Hutchings

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=1342635717.2617.57.camel@bwh-desktop.uk.solarflarecom.com \
    --to=bhutchings@solarflare.com \
    --cc=ajackson@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /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.