diff mbox

[2/3] e1000e: increase skb size to prevent dma over skb boundary (v2)

Message ID 20091207160236.GF8073@hmsreliant.think-freely.org
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Neil Horman Dec. 7, 2009, 4:02 p.m. UTC
Sorry to reply to myself, but given the comments regarding the e1000 driver, I
should take the same changes into account here.  New version of the patch, much
cleaner than previously.


Update e1000e driver to not allow dma beyond the end of the allocated sk
    
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


netdev.c |   14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Kirsher, Jeffrey T Dec. 7, 2009, 8:53 p.m. UTC | #1
On Mon, Dec 7, 2009 at 08:02, Neil Horman <nhorman@tuxdriver.com> wrote:
> Sorry to reply to myself, but given the comments regarding the e1000 driver, I
> should take the same changes into account here.  New version of the patch, much
> cleaner than previously.
>
>
> Update e1000e driver to not allow dma beyond the end of the allocated sk
>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
>
>
> netdev.c |   14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
>
> diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
> index c3105c5..84e1b5d 100644
> --- a/drivers/net/e1000e/netdev.c
> +++ b/drivers/net/e1000e/netdev.c
> @@ -2332,6 +2332,16 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
>        /* Setup buffer sizes */
>        rctl &= ~E1000_RCTL_SZ_4096;
>        rctl |= E1000_RCTL_BSEX;
> +       /*
> +        * We need to normalize the rx_buffer_len here
> +        * since the hardware only knows about 7 discrete
> +        * frame lengths here.  To accomodate that we need
> +        * to set the rx length in the hardware to the next highest
> +        * size over the rx_buffer_len, then increase rx_buffer_len
> +        * to match it, so that we can get a full mtu sized frame
> +        */
> +       adapter->rx_buffer_len = roundup_pow_of_two(adapter->rx_buffer_len);
> +
>        switch (adapter->rx_buffer_len) {
>        case 256:
>                rctl |= E1000_RCTL_SZ_256;
> @@ -2346,7 +2356,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
>                rctl &= ~E1000_RCTL_BSEX;
>                break;
>        case 2048:
> -       default:
>                rctl |= E1000_RCTL_SZ_2048;
>                rctl &= ~E1000_RCTL_BSEX;
>                break;
> @@ -2359,6 +2368,9 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
>        case 16384:
>                rctl |= E1000_RCTL_SZ_16384;
>                break;
> +       default:
> +               panic("Bad rx_buffer_len size\n");
> +               break;
>        }
>
>        /*
> --

I have added this patch to my queue of e1000e patches for
reveiw/testing.  Upon successful review/testing I will submit to
Dave/netdev.
diff mbox

Patch

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index c3105c5..84e1b5d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2332,6 +2332,16 @@  static void e1000_setup_rctl(struct e1000_adapter *adapter)
 	/* Setup buffer sizes */
 	rctl &= ~E1000_RCTL_SZ_4096;
 	rctl |= E1000_RCTL_BSEX;
+	/*
+	 * We need to normalize the rx_buffer_len here
+	 * since the hardware only knows about 7 discrete
+	 * frame lengths here.  To accomodate that we need
+	 * to set the rx length in the hardware to the next highest
+	 * size over the rx_buffer_len, then increase rx_buffer_len
+	 * to match it, so that we can get a full mtu sized frame
+	 */
+	adapter->rx_buffer_len = roundup_pow_of_two(adapter->rx_buffer_len);
+
 	switch (adapter->rx_buffer_len) {
 	case 256:
 		rctl |= E1000_RCTL_SZ_256;
@@ -2346,7 +2356,6 @@  static void e1000_setup_rctl(struct e1000_adapter *adapter)
 		rctl &= ~E1000_RCTL_BSEX;
 		break;
 	case 2048:
-	default:
 		rctl |= E1000_RCTL_SZ_2048;
 		rctl &= ~E1000_RCTL_BSEX;
 		break;
@@ -2359,6 +2368,9 @@  static void e1000_setup_rctl(struct e1000_adapter *adapter)
 	case 16384:
 		rctl |= E1000_RCTL_SZ_16384;
 		break;
+	default:
+		panic("Bad rx_buffer_len size\n");
+		break;
 	}
 
 	/*