From patchwork Fri May 9 20:16:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 347532 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 697EF1400A4 for ; Sat, 10 May 2014 06:17:15 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757370AbaEIURI (ORCPT ); Fri, 9 May 2014 16:17:08 -0400 Received: from mail-yh0-f41.google.com ([209.85.213.41]:55661 "EHLO mail-yh0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757350AbaEIURH (ORCPT ); Fri, 9 May 2014 16:17:07 -0400 Received: by mail-yh0-f41.google.com with SMTP id f73so4303027yha.28 for ; Fri, 09 May 2014 13:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pj4wE/UqF2Rubqw8/Kcta2w/XrjZ9G8EuGv9YhyVD7Y=; b=g0j0vjjQ1EX97ORIr5/Qmf0H8Yp5D2U/+3KwFuOhxeNYLNFn3rLph7gHETYZT828G3 zf52Dl1jc+/iGGMroC6CyjMJX9gov0o5uBRQrlo2tz4JDHfLJQ7GPBJzjXs0WtmIrur9 dwXgIARiRyitreOKO2knqpissIE4s3kYgVbJxfSEX44XbSqwt8iYjZnBSj4ubEM/1r5P 1lvQsOvsqa/OYOyZVwQcbLXHwd6dnptIrnZujPAD2STglSJwpJxc9bL9aEVSOiFvHctx HaimpskJ/wmnD3VEYTq8xQiPsR/L2M1rjnIFI74ifN442XUUjYD2xZQWKD6Ft3QVRWx9 DVPQ== X-Received: by 10.236.102.70 with SMTP id c46mr18307183yhg.40.1399666626729; Fri, 09 May 2014 13:17:06 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id i1sm7661288yhq.12.2014.05.09.13.17.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 May 2014 13:17:05 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: davem@davemloft.net, Florian Fainelli Subject: [PATCH net-next v4 2/2] net: systemport: pad packets to a minimum of 64 bytes Date: Fri, 9 May 2014 13:16:39 -0700 Message-Id: <1399666599-19398-3-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399666599-19398-1-git-send-email-f.fainelli@gmail.com> References: <1399666599-19398-1-git-send-email-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The switch fabric which is used behind the Broadcom SYSTEMPORT Ethernet controller will discard any incoming packet that is not 64 bytes or more. Since the UniMAC hardware transmits up to the specified size, just make sure that we properly pad the end of the packet with zeroes using skb_padto() and set a minimum packet length of 64 bytes. Signed-off-by: Florian Fainelli --- Changes in v4: - respin due to first patch Changes in v3: - reword the commit message and comment to explain the special hardware requirements - print skb_len instead of skb->len in the DMA map failure error Changes in v2: - add missing skb_padto() to zero-out packets drivers/net/ethernet/broadcom/bcmsysport.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index ac42a9e91f3a..dbae674384ea 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -821,6 +821,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, struct bcm_sysport_cb *cb; struct netdev_queue *txq; struct dma_desc *desc; + unsigned int skb_len; dma_addr_t mapping; u32 len_status; u16 queue; @@ -848,10 +849,22 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, } } - mapping = dma_map_single(kdev, skb->data, skb->len, DMA_TO_DEVICE); + /* The Ethernet switch we are interfaced with needs packets to be at + * least 64 bytes otherwise they will be discarded when they enter + * the switch port logic. The UniMAC hardware transmits up to the + * specified length. + */ + if (skb_padto(skb, 64)) { + ret = NETDEV_TX_OK; + goto out; + } + + skb_len = skb->len < 64 ? 64 : skb->len; + + mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); if (dma_mapping_error(kdev, mapping)) { netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n", - skb->data, skb->len); + skb->data, skb_len); ret = NETDEV_TX_OK; goto out; } @@ -860,14 +873,14 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb, cb = &ring->cbs[ring->curr_desc]; cb->skb = skb; dma_unmap_addr_set(cb, dma_addr, mapping); - dma_unmap_len_set(cb, dma_len, skb->len); + dma_unmap_len_set(cb, dma_len, skb_len); /* Fetch a descriptor entry from our pool */ desc = ring->desc_cpu; desc->addr_lo = lower_32_bits(mapping); len_status = upper_32_bits(mapping) & DESC_ADDR_HI_MASK; - len_status |= (skb->len << DESC_LEN_SHIFT); + len_status |= (skb_len << DESC_LEN_SHIFT); len_status |= (DESC_SOP | DESC_EOP | TX_STATUS_APP_CRC) << DESC_STATUS_SHIFT; if (skb->ip_summed == CHECKSUM_PARTIAL)