30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/netdevice.h>
56 static int numifbs = 2;
58 static void ri_tasklet(
unsigned long dev);
63 static void ri_tasklet(
unsigned long dev)
70 txq = netdev_get_tx_queue(_dev, 0);
71 if ((skb = skb_peek(&dp->
tq)) ==
NULL) {
72 if (__netif_tx_trylock(txq)) {
73 skb_queue_splice_tail_init(&dp->
rq, &dp->
tq);
74 __netif_tx_unlock(txq);
81 while ((skb = __skb_dequeue(&dp->
tq)) !=
NULL) {
87 u64_stats_update_begin(&dp->
tsync);
90 u64_stats_update_end(&dp->
tsync);
97 _dev->
stats.tx_dropped++;
98 if (skb_queue_len(&dp->
tq) != 0)
114 if (__netif_tx_trylock(txq)) {
115 if ((skb = skb_peek(&dp->
rq)) ==
NULL) {
117 if (netif_queue_stopped(_dev))
118 netif_wake_queue(_dev);
120 __netif_tx_unlock(txq);
123 __netif_tx_unlock(txq);
139 start = u64_stats_fetch_begin_bh(&dp->
rsync);
142 }
while (u64_stats_fetch_retry_bh(&dp->
rsync, start));
145 start = u64_stats_fetch_begin_bh(&dp->
tsync);
150 }
while (u64_stats_fetch_retry_bh(&dp->
tsync, start));
160 .ndo_open = ifb_open,
161 .ndo_stop = ifb_close,
162 .ndo_get_stats64 = ifb_stats64,
163 .ndo_start_xmit = ifb_xmit,
167 #define IFB_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST | \
168 NETIF_F_TSO_ECN | NETIF_F_TSO | NETIF_F_TSO6 | \
169 NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_TX)
187 eth_hw_addr_random(dev);
195 u64_stats_update_begin(&dp->
rsync);
198 u64_stats_update_end(&dp->
rsync);
202 dev->
stats.rx_dropped++;
207 netif_stop_queue(dev);
210 __skb_queue_tail(&dp->
rq, skb);
224 netif_stop_queue(dev);
225 __skb_queue_purge(&dp->
rq);
226 __skb_queue_purge(&dp->
tq);
235 __skb_queue_head_init(&dp->
rq);
236 __skb_queue_head_init(&dp->
tq);
237 netif_start_queue(dev);
245 if (nla_len(tb[IFLA_ADDRESS]) !=
ETH_ALEN)
247 if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
257 .validate = ifb_validate,
287 static int __init ifb_init_module(
void)
294 for (i = 0; i < numifbs && !
err; i++)
295 err = ifb_init_one(i);
303 static void __exit ifb_cleanup_module(
void)