Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233427
b: refs/heads/master
c: ac09664
h: refs/heads/master
i:
  233425: 18df466
  233423: a42923d
v: v3
  • Loading branch information
Toshiharu Okada authored and David S. Miller committed Feb 14, 2011
1 parent 887567c commit 0f6e292
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 539c9aa5ba7c5f71794ef0948c6dd29552f033e4
refs/heads/master: ac09664248e300342e92b937c9894a8149ddf189
97 changes: 55 additions & 42 deletions trunk/drivers/net/pch_gbe/pch_gbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const char pch_driver_version[] = DRV_VERSION;
#define PCH_GBE_SHORT_PKT 64
#define DSC_INIT16 0xC000
#define PCH_GBE_DMA_ALIGN 0
#define PCH_GBE_DMA_PADDING 2
#define PCH_GBE_WATCHDOG_PERIOD (1 * HZ) /* watchdog time */
#define PCH_GBE_COPYBREAK_DEFAULT 256
#define PCH_GBE_PCI_BAR 1
Expand Down Expand Up @@ -1365,16 +1366,13 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
struct pch_gbe_buffer *buffer_info;
struct pch_gbe_rx_desc *rx_desc;
u32 length;
unsigned char tmp_packet[ETH_HLEN];
unsigned int i;
unsigned int cleaned_count = 0;
bool cleaned = false;
struct sk_buff *skb;
struct sk_buff *skb, *new_skb;
u8 dma_status;
u16 gbec_status;
u32 tcp_ip_status;
u8 skb_copy_flag = 0;
u8 skb_padding_flag = 0;

i = rx_ring->next_to_clean;

Expand Down Expand Up @@ -1418,55 +1416,70 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
pr_err("Receive CRC Error\n");
} else {
/* get receive length */
/* length convert[-3], padding[-2] */
length = (rx_desc->rx_words_eob) - 3 - 2;
/* length convert[-3] */
length = (rx_desc->rx_words_eob) - 3;

/* Decide the data conversion method */
if (!adapter->rx_csum) {
/* [Header:14][payload] */
skb_padding_flag = 0;
skb_copy_flag = 1;
if (NET_IP_ALIGN) {
/* 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 {
/* [Header:14][padding:2][payload] */
skb_padding_flag = 1;
if (length < copybreak)
skb_copy_flag = 1;
else
skb_copy_flag = 0;
}

/* Data conversion */
if (skb_copy_flag) { /* recycle skb */
struct sk_buff *new_skb;
new_skb =
netdev_alloc_skb(netdev,
length + NET_IP_ALIGN);
if (new_skb) {
if (!skb_padding_flag) {
skb_reserve(new_skb,
NET_IP_ALIGN);
/* The length includes padding length */
length = length - PCH_GBE_DMA_PADDING;
if ((length < copybreak) ||
(NET_IP_ALIGN != PCH_GBE_DMA_PADDING)) {
/* Because alignment differs,
* the new_skb is newly allocated,
* and data is copied to new_skb.
* Padding data is deleted
* at the time of a copy.*/
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);
/* save the skb
* in buffer_info as good */
ETH_HLEN);
memcpy(&new_skb->data[ETH_HLEN],
&skb->data[ETH_HLEN +
PCH_GBE_DMA_PADDING],
length - ETH_HLEN);
skb = new_skb;
} else if (!skb_padding_flag) {
/* dorrop error */
pr_err("New skb allocation Error\n");
goto dorrop;
} else {
/* Padding data is deleted
* by moving header data.*/
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) {
memcpy(&tmp_packet[0], &skb->data[0], ETH_HLEN);
memcpy(&skb->data[NET_IP_ALIGN], &tmp_packet[0],
ETH_HLEN);
skb_reserve(skb, NET_IP_ALIGN);

}

/* The length includes FCS length */
length = length - ETH_FCS_LEN;
/* update status of driver */
adapter->stats.rx_bytes += length;
adapter->stats.rx_packets++;
Expand Down

0 comments on commit 0f6e292

Please sign in to comment.