Netdev List
 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>
Subject: [PATCH net-next 11/11] sfc: Avoid generating over-length MC_CMD_FLUSH_RX_QUEUES request
Date: Wed, 19 Sep 2012 20:18:49 +0100	[thread overview]
Message-ID: <1348082329.2636.26.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <1348081775.2636.15.camel@bwh-desktop.uk.solarflarecom.com>

MCDI supports requests up to 252 bytes long, which is only enough to
pass 63 RX queue IDs to MC_CMD_FLUSH_RX_QUEUES.  However a VF may have
up to 64 RX queues, and if we try to flush them all we will generate
an over-length request and BUG() in efx_mcdi_copyin().  Currently
all VF drivers limit themselves to 32 RX queues, so reducing the
limit to 63 does no harm.

Also add a BUILD_BUG_ON in efx_mcdi_flush_rxqs() so we remember to
deal with the same problem there if EFX_MAX_CHANNELS is increased.

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

diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index e855f4c..aea43cb 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -1195,6 +1195,9 @@ int efx_mcdi_flush_rxqs(struct efx_nic *efx)
 	__le32 *qid;
 	int rc, count;
 
+	BUILD_BUG_ON(EFX_MAX_CHANNELS >
+		     MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM);
+
 	qid = kmalloc(EFX_MAX_CHANNELS * sizeof(*qid), GFP_KERNEL);
 	if (qid == NULL)
 		return -ENOMEM;
diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c
index 9cb3b84..a8f48a4 100644
--- a/drivers/net/ethernet/sfc/siena_sriov.c
+++ b/drivers/net/ethernet/sfc/siena_sriov.c
@@ -21,6 +21,9 @@
 /* Number of longs required to track all the VIs in a VF */
 #define VI_MASK_LENGTH BITS_TO_LONGS(1 << EFX_VI_SCALE_MAX)
 
+/* Maximum number of RX queues supported */
+#define VF_MAX_RX_QUEUES 63
+
 /**
  * enum efx_vf_tx_filter_mode - TX MAC filtering behaviour
  * @VF_TX_FILTER_OFF: Disabled
@@ -578,6 +581,7 @@ static int efx_vfdi_init_rxq(struct efx_vf *vf)
 	efx_oword_t reg;
 
 	if (bad_vf_index(efx, vf_evq) || bad_vf_index(efx, vf_rxq) ||
+	    vf_rxq >= VF_MAX_RX_QUEUES ||
 	    bad_buf_count(buf_count, EFX_MAX_DMAQ_SIZE)) {
 		if (net_ratelimit())
 			netif_err(efx, hw, efx->net_dev,
@@ -683,6 +687,9 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
 	__le32 *rxqs;
 	int rc;
 
+	BUILD_BUG_ON(VF_MAX_RX_QUEUES >
+		     MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM);
+
 	rxqs = kmalloc(count * sizeof(*rxqs), GFP_KERNEL);
 	if (rxqs == NULL)
 		return VFDI_RC_ENOMEM;
-- 
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-09-19 19:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 19:09 Pull request: sfc-next 2012-09-19 Ben Hutchings
2012-09-19 19:13 ` [PATCH net-next 01/11] pps/ptp: Allow PHC devices to adjust PPS events for known delay Ben Hutchings
2012-09-20  6:57   ` Richard Cochran
2012-09-20  7:29   ` Rodolfo Giometti
2012-09-19 19:14 ` [PATCH net-next 02/11] sfc: Add explicit RX queue flag to channel Ben Hutchings
2012-09-19 19:15 ` [PATCH net-next 03/11] sfc: Add channel specific receive_skb handler and post_remove callback Ben Hutchings
2012-09-19 19:16 ` [PATCH net-next 04/11] sfc: Allow efx_mcdi_rpc to be called in two parts Ben Hutchings
2012-09-19 19:16 ` [PATCH net-next 05/11] sfc: Fix maximum array sizes for various MCDI commands Ben Hutchings
2012-09-19 19:17 ` [PATCH net-next 06/11] sfc: Add support for IEEE-1588 PTP Ben Hutchings
2012-09-20  6:59   ` Richard Cochran
2012-09-19 19:17 ` [PATCH net-next 07/11] sfc: Convert firmware subtypes to native byte order in efx_mcdi_get_board_cfg() Ben Hutchings
2012-09-19 19:17 ` [PATCH net-next 08/11] sfc: Support variable-length response to MCDI GET_BOARD_CFG Ben Hutchings
2012-09-19 19:18 ` [PATCH net-next 09/11] sfc: Expose FPGA bitfile partition through MTD Ben Hutchings
2012-09-19 19:18 ` [PATCH net-next 10/11] sfc: Bump version to 3.2 Ben Hutchings
2012-09-19 19:18 ` Ben Hutchings [this message]
2012-09-20 20:42 ` Pull request: sfc-next 2012-09-19 David Miller

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=1348082329.2636.26.camel@bwh-desktop.uk.solarflarecom.com \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox