Commit ac096642 authored by Toshiharu Okada's avatar Toshiharu Okada Committed by David S. Miller

pch_gbe: Fix the issue that the receiving data is not normal.

This PCH_GBE driver had an issue that the receiving data is not normal.
This driver had not removed correctly the padding data
which the DMA include in receiving data.

This patch fixed this issue.
Signed-off-by: default avatarToshiharu Okada <toshiharu-linux@dsn.okisemi.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 539c9aa5
...@@ -29,6 +29,7 @@ const char pch_driver_version[] = DRV_VERSION; ...@@ -29,6 +29,7 @@ const char pch_driver_version[] = DRV_VERSION;
#define PCH_GBE_SHORT_PKT 64 #define PCH_GBE_SHORT_PKT 64
#define DSC_INIT16 0xC000 #define DSC_INIT16 0xC000
#define PCH_GBE_DMA_ALIGN 0 #define PCH_GBE_DMA_ALIGN 0
#define PCH_GBE_DMA_PADDING 2
#define PCH_GBE_WATCHDOG_PERIOD (1 * HZ) /* watchdog time */ #define PCH_GBE_WATCHDOG_PERIOD (1 * HZ) /* watchdog time */
#define PCH_GBE_COPYBREAK_DEFAULT 256 #define PCH_GBE_COPYBREAK_DEFAULT 256
#define PCH_GBE_PCI_BAR 1 #define PCH_GBE_PCI_BAR 1
...@@ -1365,16 +1366,13 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, ...@@ -1365,16 +1366,13 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
struct pch_gbe_buffer *buffer_info; struct pch_gbe_buffer *buffer_info;
struct pch_gbe_rx_desc *rx_desc; struct pch_gbe_rx_desc *rx_desc;
u32 length; u32 length;
unsigned char tmp_packet[ETH_HLEN];
unsigned int i; unsigned int i;
unsigned int cleaned_count = 0; unsigned int cleaned_count = 0;
bool cleaned = false; bool cleaned = false;
struct sk_buff *skb; struct sk_buff *skb, *new_skb;
u8 dma_status; u8 dma_status;
u16 gbec_status; u16 gbec_status;
u32 tcp_ip_status; u32 tcp_ip_status;
u8 skb_copy_flag = 0;
u8 skb_padding_flag = 0;
i = rx_ring->next_to_clean; i = rx_ring->next_to_clean;
...@@ -1418,55 +1416,70 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, ...@@ -1418,55 +1416,70 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
pr_err("Receive CRC Error\n"); pr_err("Receive CRC Error\n");
} else { } else {
/* get receive length */ /* get receive length */
/* length convert[-3], padding[-2] */ /* length convert[-3] */
length = (rx_desc->rx_words_eob) - 3 - 2; length = (rx_desc->rx_words_eob) - 3;
/* Decide the data conversion method */ /* Decide the data conversion method */
if (!adapter->rx_csum) { if (!adapter->rx_csum) {
/* [Header:14][payload] */ /* [Header:14][payload] */
skb_padding_flag = 0; if (NET_IP_ALIGN) {
skb_copy_flag = 1; /* Because alignment differs,
* the new_skb is newly allocated,
* and data is copied to new_skb.*/
new_skb = netdev_alloc_skb(netdev,
length + NET_IP_ALIGN);
if (!new_skb) {
/* dorrop error */
pr_err("New skb allocation "
"Error\n");
goto dorrop;
}
skb_reserve(new_skb, NET_IP_ALIGN);
memcpy(new_skb->data, skb->data,
length);
skb = new_skb;
} else {
/* DMA buffer is used as SKB as it is.*/
buffer_info->skb = NULL;
}
} else { } else {
/* [Header:14][padding:2][payload] */ /* [Header:14][padding:2][payload] */
skb_padding_flag = 1; /* The length includes padding length */
if (length < copybreak) length = length - PCH_GBE_DMA_PADDING;
skb_copy_flag = 1; if ((length < copybreak) ||
else (NET_IP_ALIGN != PCH_GBE_DMA_PADDING)) {
skb_copy_flag = 0; /* Because alignment differs,
} * the new_skb is newly allocated,
* and data is copied to new_skb.
/* Data conversion */ * Padding data is deleted
if (skb_copy_flag) { /* recycle skb */ * at the time of a copy.*/
struct sk_buff *new_skb; new_skb = netdev_alloc_skb(netdev,
new_skb = length + NET_IP_ALIGN);
netdev_alloc_skb(netdev, if (!new_skb) {
length + NET_IP_ALIGN); /* dorrop error */
if (new_skb) { pr_err("New skb allocation "
if (!skb_padding_flag) { "Error\n");
skb_reserve(new_skb, goto dorrop;
NET_IP_ALIGN);
} }
skb_reserve(new_skb, NET_IP_ALIGN);
memcpy(new_skb->data, skb->data, memcpy(new_skb->data, skb->data,
length); ETH_HLEN);
/* save the skb memcpy(&new_skb->data[ETH_HLEN],
* in buffer_info as good */ &skb->data[ETH_HLEN +
PCH_GBE_DMA_PADDING],
length - ETH_HLEN);
skb = new_skb; skb = new_skb;
} else if (!skb_padding_flag) { } else {
/* dorrop error */ /* Padding data is deleted
pr_err("New skb allocation Error\n"); * by moving header data.*/
goto dorrop; memmove(&skb->data[PCH_GBE_DMA_PADDING],
&skb->data[0], ETH_HLEN);
skb_reserve(skb, NET_IP_ALIGN);
buffer_info->skb = NULL;
} }
} else {
buffer_info->skb = NULL;
} }
if (skb_padding_flag) { /* The length includes FCS length */
memcpy(&tmp_packet[0], &skb->data[0], ETH_HLEN); length = length - ETH_FCS_LEN;
memcpy(&skb->data[NET_IP_ALIGN], &tmp_packet[0],
ETH_HLEN);
skb_reserve(skb, NET_IP_ALIGN);
}
/* update status of driver */ /* update status of driver */
adapter->stats.rx_bytes += length; adapter->stats.rx_bytes += length;
adapter->stats.rx_packets++; adapter->stats.rx_packets++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment