aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet/pep-gprs.c
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2008-11-10 19:21:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-10 19:21:05 -0500
commit9b1582d4513a2102c68fe12ac1106595f3c09120 (patch)
treea1c5224697a63ce0c462a04cb12dfa89487a14b9 /net/phonet/pep-gprs.c
parentfb28ad35906af2f042c94e2f9c0f898ef9acfa37 (diff)
Phonet: use net_device built-in stats for GPRS
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet/pep-gprs.c')
-rw-r--r--net/phonet/pep-gprs.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index a4324075355f..e6e8e44852e5 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -41,7 +41,6 @@ struct gprs_dev {
41 void (*old_write_space)(struct sock *); 41 void (*old_write_space)(struct sock *);
42 42
43 struct net_device *net; 43 struct net_device *net;
44 struct net_device_stats stats;
45 44
46 struct sk_buff_head tx_queue; 45 struct sk_buff_head tx_queue;
47 struct work_struct tx_work; 46 struct work_struct tx_work;
@@ -83,6 +82,7 @@ static void gprs_state_change(struct sock *sk)
83 82
84static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb) 83static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
85{ 84{
85 struct net_device *net = dev->net;
86 int err = 0; 86 int err = 0;
87 __be16 protocol = gprs_type_trans(skb); 87 __be16 protocol = gprs_type_trans(skb);
88 88
@@ -99,7 +99,7 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
99 * so wrap the IP packet as a single fragment of an head-less 99 * so wrap the IP packet as a single fragment of an head-less
100 * socket buffer. The network stack will pull what it needs, 100 * socket buffer. The network stack will pull what it needs,
101 * but at least, the whole IP payload is not memcpy'd. */ 101 * but at least, the whole IP payload is not memcpy'd. */
102 rskb = netdev_alloc_skb(dev->net, 0); 102 rskb = netdev_alloc_skb(net, 0);
103 if (!rskb) { 103 if (!rskb) {
104 err = -ENOBUFS; 104 err = -ENOBUFS;
105 goto drop; 105 goto drop;
@@ -123,11 +123,11 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
123 123
124 skb->protocol = protocol; 124 skb->protocol = protocol;
125 skb_reset_mac_header(skb); 125 skb_reset_mac_header(skb);
126 skb->dev = dev->net; 126 skb->dev = net;
127 127
128 if (likely(dev->net->flags & IFF_UP)) { 128 if (likely(net->flags & IFF_UP)) {
129 dev->stats.rx_packets++; 129 net->stats.rx_packets++;
130 dev->stats.rx_bytes += skb->len; 130 net->stats.rx_bytes += skb->len;
131 netif_rx(skb); 131 netif_rx(skb);
132 skb = NULL; 132 skb = NULL;
133 } else 133 } else
@@ -136,7 +136,7 @@ static int gprs_recv(struct gprs_dev *dev, struct sk_buff *skb)
136drop: 136drop:
137 if (skb) { 137 if (skb) {
138 dev_kfree_skb(skb); 138 dev_kfree_skb(skb);
139 dev->stats.rx_dropped++; 139 net->stats.rx_dropped++;
140 } 140 }
141 return err; 141 return err;
142} 142}
@@ -199,14 +199,15 @@ static int gprs_xmit(struct sk_buff *skb, struct net_device *net)
199static void gprs_tx(struct work_struct *work) 199static void gprs_tx(struct work_struct *work)
200{ 200{
201 struct gprs_dev *dev = container_of(work, struct gprs_dev, tx_work); 201 struct gprs_dev *dev = container_of(work, struct gprs_dev, tx_work);
202 struct net_device *net = dev->net;
202 struct sock *sk = dev->sk; 203 struct sock *sk = dev->sk;
203 struct sk_buff *skb; 204 struct sk_buff *skb;
204 205
205 while ((skb = skb_dequeue(&dev->tx_queue)) != NULL) { 206 while ((skb = skb_dequeue(&dev->tx_queue)) != NULL) {
206 int err; 207 int err;
207 208
208 dev->stats.tx_bytes += skb->len; 209 net->stats.tx_bytes += skb->len;
209 dev->stats.tx_packets++; 210 net->stats.tx_packets++;
210 211
211 skb_orphan(skb); 212 skb_orphan(skb);
212 skb_set_owner_w(skb, sk); 213 skb_set_owner_w(skb, sk);
@@ -215,9 +216,9 @@ static void gprs_tx(struct work_struct *work)
215 err = pep_write(sk, skb); 216 err = pep_write(sk, skb);
216 if (err) { 217 if (err) {
217 LIMIT_NETDEBUG(KERN_WARNING"%s: TX error (%d)\n", 218 LIMIT_NETDEBUG(KERN_WARNING"%s: TX error (%d)\n",
218 dev->net->name, err); 219 net->name, err);
219 dev->stats.tx_aborted_errors++; 220 net->stats.tx_aborted_errors++;
220 dev->stats.tx_errors++; 221 net->stats.tx_errors++;
221 } 222 }
222 release_sock(sk); 223 release_sock(sk);
223 } 224 }
@@ -236,13 +237,6 @@ static int gprs_set_mtu(struct net_device *net, int new_mtu)
236 return 0; 237 return 0;
237} 238}
238 239
239static struct net_device_stats *gprs_get_stats(struct net_device *net)
240{
241 struct gprs_dev *dev = netdev_priv(net);
242
243 return &dev->stats;
244}
245
246static void gprs_setup(struct net_device *net) 240static void gprs_setup(struct net_device *net)
247{ 241{
248 net->features = NETIF_F_FRAGLIST; 242 net->features = NETIF_F_FRAGLIST;
@@ -256,7 +250,6 @@ static void gprs_setup(struct net_device *net)
256 net->destructor = free_netdev; 250 net->destructor = free_netdev;
257 net->hard_start_xmit = gprs_xmit; /* mandatory */ 251 net->hard_start_xmit = gprs_xmit; /* mandatory */
258 net->change_mtu = gprs_set_mtu; 252 net->change_mtu = gprs_set_mtu;
259 net->get_stats = gprs_get_stats;
260} 253}
261 254
262/* 255/*