Lines Matching refs:napi

931 	struct napi_struct *napi;  in dev_get_by_napi_id()  local
938 napi = napi_by_id(napi_id); in dev_get_by_napi_id()
940 return napi ? napi->dev : NULL; in dev_get_by_napi_id()
4331 struct napi_struct *napi) in ____napi_schedule() argument
4335 if (test_bit(NAPI_STATE_THREADED, &napi->state)) { in ____napi_schedule()
4342 thread = READ_ONCE(napi->thread); in ____napi_schedule()
4350 set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); in ____napi_schedule()
4356 list_add_tail(&napi->poll_list, &sd->poll_list); in ____napi_schedule()
5849 static void gro_normal_list(struct napi_struct *napi) in gro_normal_list() argument
5851 if (!napi->rx_count) in gro_normal_list()
5853 netif_receive_skb_list_internal(&napi->rx_list); in gro_normal_list()
5854 INIT_LIST_HEAD(&napi->rx_list); in gro_normal_list()
5855 napi->rx_count = 0; in gro_normal_list()
5861 static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, int segs) in gro_normal_one() argument
5863 list_add_tail(&skb->list, &napi->rx_list); in gro_normal_one()
5864 napi->rx_count += segs; in gro_normal_one()
5865 if (napi->rx_count >= gro_normal_batch) in gro_normal_one()
5866 gro_normal_list(napi); in gro_normal_one()
5869 static void napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb) in napi_gro_complete() argument
5902 gro_normal_one(napi, skb, NAPI_GRO_CB(skb)->count); in napi_gro_complete()
5905 static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index, in __napi_gro_flush_chain() argument
5908 struct list_head *head = &napi->gro_hash[index].list; in __napi_gro_flush_chain()
5915 napi_gro_complete(napi, skb); in __napi_gro_flush_chain()
5916 napi->gro_hash[index].count--; in __napi_gro_flush_chain()
5919 if (!napi->gro_hash[index].count) in __napi_gro_flush_chain()
5920 __clear_bit(index, &napi->gro_bitmask); in __napi_gro_flush_chain()
5927 void napi_gro_flush(struct napi_struct *napi, bool flush_old) in napi_gro_flush() argument
5929 unsigned long bitmask = napi->gro_bitmask; in napi_gro_flush()
5935 __napi_gro_flush_chain(napi, base, flush_old); in napi_gro_flush()
6039 static void gro_flush_oldest(struct napi_struct *napi, struct list_head *head) in gro_flush_oldest() argument
6055 napi_gro_complete(napi, oldest); in gro_flush_oldest()
6058 static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) in dev_gro_receive() argument
6061 struct gro_list *gro_list = &napi->gro_hash[bucket]; in dev_gro_receive()
6127 napi_gro_complete(napi, pp); in dev_gro_receive()
6138 gro_flush_oldest(napi, &gro_list->list); in dev_gro_receive()
6155 if (!test_bit(bucket, &napi->gro_bitmask)) in dev_gro_receive()
6156 __set_bit(bucket, &napi->gro_bitmask); in dev_gro_receive()
6157 } else if (test_bit(bucket, &napi->gro_bitmask)) { in dev_gro_receive()
6158 __clear_bit(bucket, &napi->gro_bitmask); in dev_gro_receive()
6196 static gro_result_t napi_skb_finish(struct napi_struct *napi, in napi_skb_finish() argument
6202 gro_normal_one(napi, skb, 1); in napi_skb_finish()
6223 gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) in napi_gro_receive() argument
6227 skb_mark_napi_id(skb, napi); in napi_gro_receive()
6232 ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb)); in napi_gro_receive()
6239 static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) in napi_reuse_skb() argument
6249 skb->dev = napi->dev; in napi_reuse_skb()
6265 napi->skb = skb; in napi_reuse_skb()
6268 struct sk_buff *napi_get_frags(struct napi_struct *napi) in napi_get_frags() argument
6270 struct sk_buff *skb = napi->skb; in napi_get_frags()
6273 skb = napi_alloc_skb(napi, GRO_MAX_HEAD); in napi_get_frags()
6275 napi->skb = skb; in napi_get_frags()
6276 skb_mark_napi_id(skb, napi); in napi_get_frags()
6283 static gro_result_t napi_frags_finish(struct napi_struct *napi, in napi_frags_finish() argument
6293 gro_normal_one(napi, skb, 1); in napi_frags_finish()
6300 napi_reuse_skb(napi, skb); in napi_frags_finish()
6315 static struct sk_buff *napi_frags_skb(struct napi_struct *napi) in napi_frags_skb() argument
6317 struct sk_buff *skb = napi->skb; in napi_frags_skb()
6321 napi->skb = NULL; in napi_frags_skb()
6330 __func__, napi->dev->name); in napi_frags_skb()
6331 napi_reuse_skb(napi, skb); in napi_frags_skb()
6352 gro_result_t napi_gro_frags(struct napi_struct *napi) in napi_gro_frags() argument
6355 struct sk_buff *skb = napi_frags_skb(napi); in napi_gro_frags()
6359 ret = napi_frags_finish(napi, skb, dev_gro_receive(napi, skb)); in napi_gro_frags()
6435 static int process_backlog(struct napi_struct *napi, int quota) in process_backlog() argument
6437 struct softnet_data *sd = container_of(napi, struct softnet_data, backlog); in process_backlog()
6449 napi->weight = dev_rx_weight; in process_backlog()
6474 napi->state = 0; in process_backlog()
6632 struct napi_struct *napi; in napi_by_id() local
6634 hlist_for_each_entry_rcu(napi, &napi_hash[hash], napi_hash_node) in napi_by_id()
6635 if (napi->napi_id == napi_id) in napi_by_id()
6636 return napi; in napi_by_id()
6643 static void __busy_poll_stop(struct napi_struct *napi, bool skip_schedule) in __busy_poll_stop() argument
6646 gro_normal_list(napi); in __busy_poll_stop()
6647 __napi_schedule(napi); in __busy_poll_stop()
6651 if (napi->gro_bitmask) { in __busy_poll_stop()
6655 napi_gro_flush(napi, HZ >= 1000); in __busy_poll_stop()
6658 gro_normal_list(napi); in __busy_poll_stop()
6659 clear_bit(NAPI_STATE_SCHED, &napi->state); in __busy_poll_stop()
6662 static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock, bool prefer_busy_poll, in busy_poll_stop() argument
6678 clear_bit(NAPI_STATE_MISSED, &napi->state); in busy_poll_stop()
6679 clear_bit(NAPI_STATE_IN_BUSY_POLL, &napi->state); in busy_poll_stop()
6684 napi->defer_hard_irqs_count = READ_ONCE(napi->dev->napi_defer_hard_irqs); in busy_poll_stop()
6685 timeout = READ_ONCE(napi->dev->gro_flush_timeout); in busy_poll_stop()
6686 if (napi->defer_hard_irqs_count && timeout) { in busy_poll_stop()
6687 hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED); in busy_poll_stop()
6695 rc = napi->poll(napi, budget); in busy_poll_stop()
6700 trace_napi_poll(napi, rc, budget); in busy_poll_stop()
6703 __busy_poll_stop(napi, skip_schedule); in busy_poll_stop()
6712 int (*napi_poll)(struct napi_struct *napi, int budget); in napi_busy_loop()
6714 struct napi_struct *napi; in napi_busy_loop() local
6721 napi = napi_by_id(napi_id); in napi_busy_loop()
6722 if (!napi) in napi_busy_loop()
6731 unsigned long val = READ_ONCE(napi->state); in napi_busy_loop()
6739 set_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_busy_loop()
6742 if (cmpxchg(&napi->state, val, in napi_busy_loop()
6746 set_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_busy_loop()
6749 have_poll_lock = netpoll_poll_lock(napi); in napi_busy_loop()
6750 napi_poll = napi->poll; in napi_busy_loop()
6752 work = napi_poll(napi, budget); in napi_busy_loop()
6753 trace_napi_poll(napi, work, budget); in napi_busy_loop()
6754 gro_normal_list(napi); in napi_busy_loop()
6757 __NET_ADD_STATS(dev_net(napi->dev), in napi_busy_loop()
6766 busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget); in napi_busy_loop()
6777 busy_poll_stop(napi, have_poll_lock, prefer_busy_poll, budget); in napi_busy_loop()
6786 static void napi_hash_add(struct napi_struct *napi) in napi_hash_add() argument
6788 if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state)) in napi_hash_add()
6798 napi->napi_id = napi_gen_id; in napi_hash_add()
6800 hlist_add_head_rcu(&napi->napi_hash_node, in napi_hash_add()
6801 &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); in napi_hash_add()
6809 static void napi_hash_del(struct napi_struct *napi) in napi_hash_del() argument
6813 hlist_del_init_rcu(&napi->napi_hash_node); in napi_hash_del()
6820 struct napi_struct *napi; in napi_watchdog() local
6822 napi = container_of(timer, struct napi_struct, timer); in napi_watchdog()
6827 if (!napi_disable_pending(napi) && in napi_watchdog()
6828 !test_and_set_bit(NAPI_STATE_SCHED, &napi->state)) { in napi_watchdog()
6829 clear_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state); in napi_watchdog()
6830 __napi_schedule_irqoff(napi); in napi_watchdog()
6836 static void init_gro_hash(struct napi_struct *napi) in init_gro_hash() argument
6841 INIT_LIST_HEAD(&napi->gro_hash[i].list); in init_gro_hash()
6842 napi->gro_hash[i].count = 0; in init_gro_hash()
6844 napi->gro_bitmask = 0; in init_gro_hash()
6849 struct napi_struct *napi; in dev_set_threaded() local
6856 list_for_each_entry(napi, &dev->napi_list, dev_list) { in dev_set_threaded()
6857 if (!napi->thread) { in dev_set_threaded()
6858 err = napi_kthread_create(napi); in dev_set_threaded()
6880 list_for_each_entry(napi, &dev->napi_list, dev_list) { in dev_set_threaded()
6882 set_bit(NAPI_STATE_THREADED, &napi->state); in dev_set_threaded()
6884 clear_bit(NAPI_STATE_THREADED, &napi->state); in dev_set_threaded()
6891 void netif_napi_add(struct net_device *dev, struct napi_struct *napi, in netif_napi_add() argument
6894 if (WARN_ON(test_and_set_bit(NAPI_STATE_LISTED, &napi->state))) in netif_napi_add()
6897 INIT_LIST_HEAD(&napi->poll_list); in netif_napi_add()
6898 INIT_HLIST_NODE(&napi->napi_hash_node); in netif_napi_add()
6899 hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); in netif_napi_add()
6900 napi->timer.function = napi_watchdog; in netif_napi_add()
6901 init_gro_hash(napi); in netif_napi_add()
6902 napi->skb = NULL; in netif_napi_add()
6903 INIT_LIST_HEAD(&napi->rx_list); in netif_napi_add()
6904 napi->rx_count = 0; in netif_napi_add()
6905 napi->poll = poll; in netif_napi_add()
6909 napi->weight = weight; in netif_napi_add()
6910 napi->dev = dev; in netif_napi_add()
6912 napi->poll_owner = -1; in netif_napi_add()
6914 set_bit(NAPI_STATE_SCHED, &napi->state); in netif_napi_add()
6915 set_bit(NAPI_STATE_NPSVC, &napi->state); in netif_napi_add()
6916 list_add_rcu(&napi->dev_list, &dev->napi_list); in netif_napi_add()
6917 napi_hash_add(napi); in netif_napi_add()
6922 if (dev->threaded && napi_kthread_create(napi)) in netif_napi_add()
6976 static void flush_gro_hash(struct napi_struct *napi) in flush_gro_hash() argument
6983 list_for_each_entry_safe(skb, n, &napi->gro_hash[i].list, list) in flush_gro_hash()
6985 napi->gro_hash[i].count = 0; in flush_gro_hash()
6990 void __netif_napi_del(struct napi_struct *napi) in __netif_napi_del() argument
6992 if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state)) in __netif_napi_del()
6995 napi_hash_del(napi); in __netif_napi_del()
6996 list_del_rcu(&napi->dev_list); in __netif_napi_del()
6997 napi_free_frags(napi); in __netif_napi_del()
6999 flush_gro_hash(napi); in __netif_napi_del()
7000 napi->gro_bitmask = 0; in __netif_napi_del()
7002 if (napi->thread) { in __netif_napi_del()
7003 kthread_stop(napi->thread); in __netif_napi_del()
7004 napi->thread = NULL; in __netif_napi_del()
7100 static int napi_thread_wait(struct napi_struct *napi) in napi_thread_wait() argument
7112 if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) { in napi_thread_wait()
7113 WARN_ON(!list_empty(&napi->poll_list)); in napi_thread_wait()
7130 struct napi_struct *napi = data; in napi_threaded_poll() local
7133 while (!napi_thread_wait(napi)) { in napi_threaded_poll()
7139 have = netpoll_poll_lock(napi); in napi_threaded_poll()
7140 __napi_poll(napi, &repoll); in napi_threaded_poll()
11319 struct napi_struct *napi = list_first_entry(&oldsd->poll_list, in dev_cpu_dead() local
11323 list_del_init(&napi->poll_list); in dev_cpu_dead()
11324 if (napi->poll == process_backlog) in dev_cpu_dead()
11325 napi->state = 0; in dev_cpu_dead()
11327 ____napi_schedule(sd, napi); in dev_cpu_dead()