Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH

From: Masayuki Ohtake
Date: Thu Sep 02 2010 - 08:39:47 EST


Hi Eric

Thank you for your comments.

> I find hard to believe this driver needs to copy all outgoing frames on
> pre-allocated skbs.
>
> + /* [Header:14][payload] ---> [Header:14][paddong:2][payload] */
> + memcpy(tmp_skb->data, skb->data, ETH_HLEN);
> + tmp_skb->data[ETH_HLEN] = 0x00;
> + tmp_skb->data[ETH_HLEN + 1] = 0x00;
> + tmp_skb->len = skb->len;
> + memcpy(&tmp_skb->data[ETH_HLEN + 2], &skb->data[ETH_HLEN],
> + (skb->len - ETH_HLEN));
> + buffer_info->kernel_skb = skb;
> + skb = tmp_skb;
>
> Whats the deal here please ?

This processing depends on hardware specification.

At the time of transmission.
Hardware accepts a packet in the following format.
[Header: 14octet] + [padding: 2octet] + [payload]
Also, it is necessary to align the head of a [Header: 14octet] at 64byte.

In my knowledge, SKB received by kernel are the following format.
[padding: 2octet] + [Header:14octet] + [payload]
Also, The head of [payload] has aligned at 16 byte.

So, it has adjusted with the format of hardware by a copy.

Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Eric Dumazet" <eric.dumazet@xxxxxxxxx>
To: "Masayuki Ohtake" <masa-korg@xxxxxxxxxxxxxxx>
Cc: "Stephen Hemminger" <shemminger@xxxxxxxxxx>; "Sam Ravnborg" <sam@xxxxxxxxxxxx>; "Joe Perches" <joe@xxxxxxxxxxx>;
"LKML" <linux-kernel@xxxxxxxxxxxxxxx>; "ML netdev" <netdev@xxxxxxxxxxxxxxx>; "Greg Rose" <gregory.v.rose@xxxxxxxxx>;
"Maxime Bizon" <mbizon@xxxxxxxxxx>; "Kristoffer Glembo" <kristoffer@xxxxxxxxxxx>; "Ralf Baechle" <ralf@xxxxxxxxxxxxxx>;
"John Linn" <john.linn@xxxxxxxxxx>; "Randy Dunlap" <randy.dunlap@xxxxxxxxxx>; "David S. Miller" <davem@xxxxxxxxxxxxx>;
"MeeGo" <meego-dev@xxxxxxxxx>; "Wang, Qi" <qi.wang@xxxxxxxxx>; "Wang, Yong Y" <yong.y.wang@xxxxxxxxx>; "Andrew"
<andrew.chih.howe.khor@xxxxxxxxx>; "Intel OTC" <joel.clark@xxxxxxxxx>; "Foster, Margie" <margie.foster@xxxxxxxxx>;
"Toshiharu Okada" <okada533@xxxxxxxxxxxxxxx>; "Tomoya Morinaga" <morinaga526@xxxxxxxxxxxxxxx>; "Takahiro Shimizu"
<shimizu394@xxxxxxxxxxxxxxx>
Sent: Tuesday, August 31, 2010 11:51 PM
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH


> Le mardi 31 aout 2010 a 23:15 +0900, Masayuki Ohtake a ecrit :
> > Hi Sam, Joe and Stephen
> >
> > Thank you for your comments.
> > We have modified this driver for your comment.
> >
> > ---
> > Gigabit Ethernet driver of Topcliff PCH
>
> > + skb->protocol = eth_type_trans(skb, netdev);
> > + if ((tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) ==
> > + PCH_GBE_RXD_ACC_STAT_TCPIPOK) {
> > + skb->ip_summed = CHECKSUM_UNNECESSARY;
> > + } else {
> > + skb->ip_summed = CHECKSUM_NONE;
> > + }
> > +
> > + if (netif_receive_skb(skb) == NET_RX_DROP) {
> > + adapter->stats.rx_dropped++;
>
> dont use pr_err() here, dropping a frame is a normal condition.
>
> > + pr_err("Receive Netif Receive Dropped Error\n");
> > + }
> > + (*work_done)++;
> > + netdev->last_rx = jiffies;
>
> really ? last_rx is a thing of the past.
>
> > + pr_debug
> > + ("Receive skb->ip_summed: %d length: %d\n",
> > + skb->ip_summed, length);
> > + }
> > +dorrop:
> > + /* return some buffers to hardware, one at a time is too slow */
> > + if (unlikely(cleaned_count >= PCH_GBE_RX_BUFFER_WRITE)) {
> > + pch_gbe_alloc_rx_buffers(adapter, rx_ring,
> > + cleaned_count);
> > + cleaned_count = 0;
> > + }
> > + if (++i == rx_ring->count)
> > + i = 0;
> > + }
> > + rx_ring->next_to_clean = i;
> > + if (cleaned_count)
> > + pch_gbe_alloc_rx_buffers(adapter, rx_ring, cleaned_count);
> > + return cleaned;
> > +}
> > +
>
>
>
> I find hard to believe this driver needs to copy all outgoing frames on
> pre-allocated skbs.
>
> + /* [Header:14][payload] ---> [Header:14][paddong:2][payload] */
> + memcpy(tmp_skb->data, skb->data, ETH_HLEN);
> + tmp_skb->data[ETH_HLEN] = 0x00;
> + tmp_skb->data[ETH_HLEN + 1] = 0x00;
> + tmp_skb->len = skb->len;
> + memcpy(&tmp_skb->data[ETH_HLEN + 2], &skb->data[ETH_HLEN],
> + (skb->len - ETH_HLEN));
> + buffer_info->kernel_skb = skb;
> + skb = tmp_skb;
>
> Whats the deal here please ?
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/