* [PATCH 2/2] hv: handle skb allocation failure
[not found] ` <20100309173855.7d297c44@nehalam>
@ 2010-03-10 1:42 ` Stephen Hemminger
2010-03-11 17:11 ` [PATCH] hv: name network device ethX rather than sethX Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2010-03-10 1:42 UTC (permalink / raw)
To: Hank Janssen, Greg KH; +Cc: netdev
Some fixes to receive handling:
* Dieing with assertion failure when running out of memory is not ok
* Use newer alloc function to get aligned skb
* Dropped statistic is supposed to be incremented only by
driver it was responsible for the drop.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
drivers/staging/hv/netvsc_drv.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
--- a/drivers/staging/hv/netvsc_drv.c 2010-03-09 17:27:57.263312289 -0800
+++ b/drivers/staging/hv/netvsc_drv.c 2010-03-09 17:34:45.012686682 -0800
@@ -292,7 +292,6 @@ static int netvsc_recv_callback(struct h
struct net_device_context *net_device_ctx;
struct sk_buff *skb;
void *data;
- int ret;
int i;
unsigned long flags;
@@ -306,12 +305,12 @@ static int netvsc_recv_callback(struct h
net_device_ctx = netdev_priv(net);
- /* Allocate a skb - TODO preallocate this */
- /* Pad 2-bytes to align IP header to 16 bytes */
- skb = dev_alloc_skb(packet->TotalDataBufferLength + 2);
- ASSERT(skb);
- skb_reserve(skb, 2);
- skb->dev = net;
+ /* Allocate a skb - TODO direct I/O to pages? */
+ skb = netdev_alloc_skb_ip_align(net, packet->TotalDataBufferLength);
+ if (unlikely(!skb)) {
+ ++net->stats.rx_dropped;
+ return 0;
+ }
/* for kmap_atomic */
local_irq_save(flags);
@@ -336,25 +335,18 @@ static int netvsc_recv_callback(struct h
local_irq_restore(flags);
skb->protocol = eth_type_trans(skb, net);
-
skb->ip_summed = CHECKSUM_NONE;
+ net->stats.rx_packets++;
+ net->stats.rx_bytes += skb->len;
+
/*
* Pass the skb back up. Network stack will deallocate the skb when it
- * is done
+ * is done.
+ * TODO - use NAPI?
*/
- ret = netif_rx(skb);
-
- switch (ret) {
- case NET_RX_DROP:
- net->stats.rx_dropped++;
- break;
- default:
- net->stats.rx_packets++;
- net->stats.rx_bytes += skb->len;
- break;
+ netif_rx(skb);
- }
DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
net->stats.rx_packets, net->stats.rx_bytes);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] hv: use network device stats
[not found] ` <8AFC7968D54FB448A30D8F38F259C5621AF725A9@TK5EX14MBXC116.redmond.corp.microsoft.com>
[not found] ` <20100309173855.7d297c44@nehalam>
@ 2010-03-10 1:42 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2010-03-10 1:42 UTC (permalink / raw)
To: Hank Janssen, Greg KH; +Cc: netdev
The network device structure has space already reserved for statistics.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
drivers/staging/hv/TODO | 1 -
drivers/staging/hv/netvsc_drv.c | 31 +++++++++----------------------
2 files changed, 9 insertions(+), 23 deletions(-)
--- a/drivers/staging/hv/TODO 2010-03-09 17:07:51.483312299 -0800
+++ b/drivers/staging/hv/TODO 2010-03-09 17:08:05.812720241 -0800
@@ -9,7 +9,6 @@ TODO:
- see if the vmbus can be merged with the other virtual busses
in the kernel
- audit the network driver
- - use existing net_device_stats struct in network device
- checking for carrier inside open is wrong, network device API
confusion??
- audit the block driver
--- a/drivers/staging/hv/netvsc_drv.c 2010-03-09 17:04:48.453624589 -0800
+++ b/drivers/staging/hv/netvsc_drv.c 2010-03-09 17:25:21.196552131 -0800
@@ -42,7 +42,6 @@
struct net_device_context {
/* point back to our device context */
struct vm_device *device_ctx;
- struct net_device_stats stats;
};
struct netvsc_driver_context {
@@ -57,13 +56,6 @@ static int netvsc_ringbuffer_size = NETV
/* The one and only one */
static struct netvsc_driver_context g_netvsc_drv;
-static struct net_device_stats *netvsc_get_stats(struct net_device *net)
-{
- struct net_device_context *net_device_ctx = netdev_priv(net);
-
- return &net_device_ctx->stats;
-}
-
static void netvsc_set_multicast_list(struct net_device *net)
{
}
@@ -77,9 +69,6 @@ static int netvsc_open(struct net_device
DPRINT_ENTER(NETVSC_DRV);
if (netif_carrier_ok(net)) {
- memset(&net_device_ctx->stats, 0,
- sizeof(struct net_device_stats));
-
/* Open up the device */
ret = RndisFilterOnOpen(device_obj);
if (ret != 0) {
@@ -223,8 +212,8 @@ retry_send:
if (ret == 0) {
ret = NETDEV_TX_OK;
- net_device_ctx->stats.tx_bytes += skb->len;
- net_device_ctx->stats.tx_packets++;
+ net->stats.tx_bytes += skb->len;
+ net->stats.tx_packets++;
} else {
retries++;
if (retries < 4) {
@@ -240,7 +229,7 @@ retry_send:
DPRINT_INFO(NETVSC_DRV, "net device (%p) stopping", net);
ret = NETDEV_TX_BUSY;
- net_device_ctx->stats.tx_dropped++;
+ net->stats.tx_dropped++;
netif_stop_queue(net);
@@ -258,8 +247,8 @@ retry_send:
}
DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu",
- net_device_ctx->stats.tx_packets,
- net_device_ctx->stats.tx_bytes);
+ net->stats.tx_packets,
+ net->stats.tx_bytes);
DPRINT_EXIT(NETVSC_DRV);
return ret;
@@ -358,17 +347,16 @@ static int netvsc_recv_callback(struct h
switch (ret) {
case NET_RX_DROP:
- net_device_ctx->stats.rx_dropped++;
+ net->stats.rx_dropped++;
break;
default:
- net_device_ctx->stats.rx_packets++;
- net_device_ctx->stats.rx_bytes += skb->len;
+ net->stats.rx_packets++;
+ net->stats.rx_bytes += skb->len;
break;
}
DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
- net_device_ctx->stats.rx_packets,
- net_device_ctx->stats.rx_bytes);
+ net->stats.rx_packets, net->stats.rx_bytes);
DPRINT_EXIT(NETVSC_DRV);
@@ -379,7 +367,6 @@ static const struct net_device_ops devic
.ndo_open = netvsc_open,
.ndo_stop = netvsc_close,
.ndo_start_xmit = netvsc_start_xmit,
- .ndo_get_stats = netvsc_get_stats,
.ndo_set_multicast_list = netvsc_set_multicast_list,
};
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] hv: name network device ethX rather than sethX
2010-03-10 1:42 ` [PATCH 2/2] hv: handle skb allocation failure Stephen Hemminger
@ 2010-03-11 17:11 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2010-03-11 17:11 UTC (permalink / raw)
To: Hank Janssen; +Cc: Greg KH, netdev
This patch makes the HyperV network device use the same naming
scheme as other virtual drivers (Xen, KVM). In an ideal world,
userspace tools would not care what the name is, but some
users and applications do care. Vyatta CLI is one of the tools
that does depend on what the name is.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
drivers/staging/hv/netvsc_drv.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
--- a/drivers/staging/hv/netvsc_drv.c 2010-03-09 17:34:45.012686682 -0800
+++ b/drivers/staging/hv/netvsc_drv.c 2010-03-11 09:08:00.480877949 -0800
@@ -381,8 +381,7 @@ static int netvsc_probe(struct device *d
if (!net_drv_obj->Base.OnDeviceAdd)
return -1;
- net = alloc_netdev(sizeof(struct net_device_context), "seth%d",
- ether_setup);
+ net = alloc_etherdev(sizeof(struct net_device_context));
if (!net)
return -1;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-11 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <AD02C96F1FB40A4B896D24F974E9B9D42AA4787A@TK5EX14MBXC139.redmond.corp.microsoft.com>
[not found] ` <20100308154549.1c62a33b@nehalam>
[not found] ` <8AFC7968D54FB448A30D8F38F259C5621AF725A9@TK5EX14MBXC116.redmond.corp.microsoft.com>
[not found] ` <20100309173855.7d297c44@nehalam>
2010-03-10 1:42 ` [PATCH 2/2] hv: handle skb allocation failure Stephen Hemminger
2010-03-11 17:11 ` [PATCH] hv: name network device ethX rather than sethX Stephen Hemminger
2010-03-10 1:42 ` [PATCH 1/2] hv: use network device stats Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).