Lines Matching refs:napi

925 	struct napi_struct *napi;  in dev_get_by_napi_id()  local
932 napi = napi_by_id(napi_id); in dev_get_by_napi_id()
934 return napi ? napi->dev : NULL; in dev_get_by_napi_id()
4311 struct napi_struct *napi) in ____napi_schedule() argument
4315 if (test_bit(NAPI_STATE_THREADED, &napi->state)) { in ____napi_schedule()
4322 thread = READ_ONCE(napi->thread); in ____napi_schedule()
4330 set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); in ____napi_schedule()
4336 list_add_tail(&napi->poll_list, &sd->poll_list); in ____napi_schedule()
5827 static void gro_normal_list(struct napi_struct *napi) in gro_normal_list() argument
5829 if (!napi->rx_count) in gro_normal_list()
5831 netif_receive_skb_list_internal(&napi->rx_list); in gro_normal_list()
5832 INIT_LIST_HEAD(&napi->rx_list); in gro_normal_list()
5833 napi->rx_count = 0; in gro_normal_list()
5839 static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, int segs) in gro_normal_one() argument
5841 list_add_tail(&skb->list, &napi->rx_list); in gro_normal_one()
5842 napi->rx_count += segs; in gro_normal_one()
5843 if (napi->rx_count >= gro_normal_batch) in gro_normal_one()
5844 gro_normal_list(napi); in gro_normal_one()
5847 static int napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb) in napi_gro_complete() argument
5880 gro_normal_one(napi, skb, NAPI_GRO_CB(skb)->count); in napi_gro_complete()
5884 static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index, in __napi_gro_flush_chain() argument
5887 struct list_head *head = &napi->gro_hash[index].list; in __napi_gro_flush_chain()
5894 napi_gro_complete(napi, skb); in __napi_gro_flush_chain()
5895 napi->gro_hash[index].count--; in __napi_gro_flush_chain()
5898 if (!napi->gro_hash[index].count) in __napi_gro_flush_chain()
5899 __clear_bit(index, &napi->gro_bitmask); in __napi_gro_flush_chain()
5906 void napi_gro_flush(struct napi_struct *napi, bool flush_old) in napi_gro_flush() argument
5908 unsigned long bitmask = napi->gro_bitmask; in napi_gro_flush()
5914 __napi_gro_flush_chain(napi, base, flush_old); in napi_gro_flush()
6018 static void gro_flush_oldest(struct napi_struct *napi, struct list_head *head) in gro_flush_oldest() argument
6034 napi_gro_complete(napi, oldest); in gro_flush_oldest()
6037 static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) in dev_gro_receive() argument
6040 struct gro_list *gro_list = &napi->gro_hash[bucket]; in dev_gro_receive()
6106 napi_gro_complete(napi, pp); in dev_gro_receive()
6117 gro_flush_oldest(napi, &gro_list->list); in dev_gro_receive()
6134 if (!test_bit(bucket, &napi->gro_bitmask)) in dev_gro_receive()
6135 __set_bit(bucket, &napi->gro_bitmask); in dev_gro_receive()
6136 } else if (test_bit(bucket, &napi->gro_bitmask)) { in dev_gro_receive()
6137 __clear_bit(bucket, &napi->gro_bitmask); in dev_gro_receive()
6175 static gro_result_t napi_skb_finish(struct napi_struct *napi, in napi_skb_finish() argument
6181 gro_normal_one(napi, skb, 1); in napi_skb_finish()
6202 gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) in napi_gro_receive() argument
6206 skb_mark_napi_id(skb, napi); in napi_gro_receive()
6211 ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb)); in napi_gro_receive()
6218 static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) in napi_reuse_skb() argument
6228 skb->dev = napi->dev; in napi_reuse_skb()
6244 napi->skb = skb; in napi_reuse_skb()
6247 struct sk_buff *napi_get_frags(struct napi_struct *napi) in napi_get_frags() argument
6249 struct sk_buff *skb = napi->skb; in napi_get_frags()
6252 skb = napi_alloc_skb(napi, GRO_MAX_HEAD); in napi_get_frags()
6254 napi->skb = skb; in napi_get_frags()
6255 skb_mark_napi_id(skb, napi); in napi_get_frags()
6262 static gro_result_t napi_frags_finish(struct napi_struct *napi, in napi_frags_finish() argument
6272 gro_normal_one(napi, skb, 1); in napi_frags_finish()
6279 napi_reuse_skb(napi, skb); in napi_frags_finish()
6294 static struct sk_buff *napi_frags_skb(struct napi_struct *napi) in napi_frags_skb() argument
6296 struct sk_buff *skb = napi->skb; in napi_frags_skb()
6300 napi->skb = NULL; in napi_frags_skb()
6309 __func__, napi->dev->name); in napi_frags_skb()
6310 napi_reuse_skb(napi, skb); in napi_frags_skb()
6331 gro_result_t napi_gro_frags(struct napi_struct *napi) in napi_gro_frags() argument
6334 struct sk_buff *skb = napi_frags_skb(napi); in napi_gro_frags()
6338 ret = napi_frags_finish(napi, skb, dev_gro_receive(napi, skb)); in napi_gro_frags()
6414 static int process_backlog(struct napi_struct *napi, int quota) in process_backlog() argument
6416 struct softnet_data *sd = container_of(napi, struct softnet_data, backlog); in process_backlog()
6428 napi->weight = dev_rx_weight; in process_backlog()
6453 napi->state = 0; in process_backlog()
6611 struct napi_struct *napi; in napi_by_id() local
6613 hlist_for_each_entry_rcu(napi, &napi_hash[hash], napi_hash_node) in napi_by_id()
6614 if (napi->napi_id == napi_id) in napi_by_id()
6615 return napi; in napi_by_id()
6622 static void __busy_poll_stop(struct napi_struct *napi, bool skip_schedule) in __busy_poll_stop() argument
6625 gro_normal_list(napi); in __busy_poll_stop()
6626 __napi_schedule(napi); in __busy_poll_stop()
6630 if (napi->gro_bitmask) { in __busy_poll_stop()
6634 napi_gro_flush(napi, HZ >= 1000); in __busy_poll_stop()
6637 gro_normal_list(napi); in __busy_poll_stop()
6638 clear_bit(NAPI_STATE_SCHED, &napi->state); in __busy_poll_stop()
6641 static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock, bool prefer_busy_poll, in busy_poll_stop() argument
6657 clear_bit(NAPI_STATE_MISSED, &napi->state); in busy_poll_stop()
6658 clear_bit(NAPI_STATE_IN_BUSY_POLL, &napi->state); in busy_poll_stop()
6663 napi->defer_hard_irqs_count = READ_ONCE(napi->dev->napi_defer_hard_irqs); in busy_poll_stop()
6664 timeout = READ_ONCE(napi->dev->gro_flush_timeout); in busy_poll_stop()
6665 if (napi->defer_hard_irqs_count && timeout) { in busy_poll_stop()
6666 hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED); in busy_poll_stop()
6674 rc = napi->poll(napi, budget); in busy_poll_stop()
6679 trace_napi_poll(napi, rc, budget); in busy_poll_stop()
6682 __busy_poll_stop(napi, skip_schedule); in busy_poll_stop()
6691 int (*napi_poll)(struct napi_struct *napi, int budget); in napi_busy_loop()
6693 struct napi_struct *napi; in napi_busy_loop() local
6700 napi = napi_by_id(napi_id); in napi_busy_loop()
6701 if (!napi) in napi_busy_loop()
6710 unsigned long val = READ_ONCE(napi->state); in napi_busy_loop()
6718 set_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_busy_loop()
6721 if (cmpxchg(&napi->state, val, in napi_busy_loop()
6725 set_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_busy_loop()
6728 have_poll_lock = netpoll_poll_lock(napi); in napi_busy_loop()
6729 napi_poll = napi->poll; in napi_busy_loop()
6731 work = napi_poll(napi, budget); in napi_busy_loop()
6732 trace_napi_poll(napi, work, budget); in napi_busy_loop()
6733 gro_normal_list(napi); in napi_busy_loop()
6736 __NET_ADD_STATS(dev_net(napi->dev), in napi_busy_loop()
6745 busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget); in napi_busy_loop()
6756 busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget); in napi_busy_loop()
6765 static void napi_hash_add(struct napi_struct *napi) in napi_hash_add() argument
6767 if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state)) in napi_hash_add()
6777 napi->napi_id = napi_gen_id; in napi_hash_add()
6779 hlist_add_head_rcu(&napi->napi_hash_node, in napi_hash_add()
6780 &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); in napi_hash_add()
6788 static void napi_hash_del(struct napi_struct *napi) in napi_hash_del() argument
6792 hlist_del_init_rcu(&napi->napi_hash_node); in napi_hash_del()
6799 struct napi_struct *napi; in napi_watchdog() local
6801 napi = container_of(timer, struct napi_struct, timer); in napi_watchdog()
6806 if (!napi_disable_pending(napi) && in napi_watchdog()
6807 !test_and_set_bit(NAPI_STATE_SCHED, &napi->state)) { in napi_watchdog()
6808 clear_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_watchdog()
6809 __napi_schedule_irqoff(napi); in napi_watchdog()
6815 static void init_gro_hash(struct napi_struct *napi) in init_gro_hash() argument
6820 INIT_LIST_HEAD(&napi->gro_hash[i].list); in init_gro_hash()
6821 napi->gro_hash[i].count = 0; in init_gro_hash()
6823 napi->gro_bitmask = 0; in init_gro_hash()
6828 struct napi_struct *napi; in dev_set_threaded() local
6835 list_for_each_entry(napi, &dev->napi_list, dev_list) { in dev_set_threaded()
6836 if (!napi->thread) { in dev_set_threaded()
6837 err = napi_kthread_create(napi); in dev_set_threaded()
6859 list_for_each_entry(napi, &dev->napi_list, dev_list) { in dev_set_threaded()
6861 set_bit(NAPI_STATE_THREADED, &napi->state); in dev_set_threaded()
6863 clear_bit(NAPI_STATE_THREADED, &napi->state); in dev_set_threaded()
6870 void netif_napi_add(struct net_device *dev, struct napi_struct *napi, in netif_napi_add() argument
6873 if (WARN_ON(test_and_set_bit(NAPI_STATE_LISTED, &napi->state))) in netif_napi_add()
6876 INIT_LIST_HEAD(&napi->poll_list); in netif_napi_add()
6877 INIT_HLIST_NODE(&napi->napi_hash_node); in netif_napi_add()
6878 hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); in netif_napi_add()
6879 napi->timer.function = napi_watchdog; in netif_napi_add()
6880 init_gro_hash(napi); in netif_napi_add()
6881 napi->skb = NULL; in netif_napi_add()
6882 INIT_LIST_HEAD(&napi->rx_list); in netif_napi_add()
6883 napi->rx_count = 0; in netif_napi_add()
6884 napi->poll = poll; in netif_napi_add()
6888 napi->weight = weight; in netif_napi_add()
6889 napi->dev = dev; in netif_napi_add()
6891 napi->poll_owner = -1; in netif_napi_add()
6893 set_bit(NAPI_STATE_SCHED, &napi->state); in netif_napi_add()
6894 set_bit(NAPI_STATE_NPSVC, &napi->state); in netif_napi_add()
6895 list_add_rcu(&napi->dev_list, &dev->napi_list); in netif_napi_add()
6896 napi_hash_add(napi); in netif_napi_add()
6901 if (dev->threaded && napi_kthread_create(napi)) in netif_napi_add()
6946 static void flush_gro_hash(struct napi_struct *napi) in flush_gro_hash() argument
6953 list_for_each_entry_safe(skb, n, &napi->gro_hash[i].list, list) in flush_gro_hash()
6955 napi->gro_hash[i].count = 0; in flush_gro_hash()
6960 void __netif_napi_del(struct napi_struct *napi) in __netif_napi_del() argument
6962 if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state)) in __netif_napi_del()
6965 napi_hash_del(napi); in __netif_napi_del()
6966 list_del_rcu(&napi->dev_list); in __netif_napi_del()
6967 napi_free_frags(napi); in __netif_napi_del()
6969 flush_gro_hash(napi); in __netif_napi_del()
6970 napi->gro_bitmask = 0; in __netif_napi_del()
6972 if (napi->thread) { in __netif_napi_del()
6973 kthread_stop(napi->thread); in __netif_napi_del()
6974 napi->thread = NULL; in __netif_napi_del()
7070 static int napi_thread_wait(struct napi_struct *napi) in napi_thread_wait() argument
7082 if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) { in napi_thread_wait()
7083 WARN_ON(!list_empty(&napi->poll_list)); in napi_thread_wait()
7100 struct napi_struct *napi = data; in napi_threaded_poll() local
7103 while (!napi_thread_wait(napi)) { in napi_threaded_poll()
7109 have = netpoll_poll_lock(napi); in napi_threaded_poll()
7110 __napi_poll(napi, &repoll); in napi_threaded_poll()
11289 struct napi_struct *napi = list_first_entry(&oldsd->poll_list, in dev_cpu_dead() local
11293 list_del_init(&napi->poll_list); in dev_cpu_dead()
11294 if (napi->poll == process_backlog) in dev_cpu_dead()
11295 napi->state = 0; in dev_cpu_dead()
11297 ____napi_schedule(sd, napi); in dev_cpu_dead()