netdev_rx_queue.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_NETDEV_RX_QUEUE_H
  3. #define _LINUX_NETDEV_RX_QUEUE_H
  4. #include <linux/kobject.h>
  5. #include <linux/netdevice.h>
  6. #include <linux/sysfs.h>
  7. #include <net/xdp.h>
  8. #include <net/page_pool/types.h>
  9. /* This structure contains an instance of an RX queue. */
  10. struct netdev_rx_queue {
  11. struct xdp_rxq_info xdp_rxq;
  12. #ifdef CONFIG_RPS
  13. struct rps_map __rcu *rps_map;
  14. struct rps_dev_flow_table __rcu *rps_flow_table;
  15. #endif
  16. struct kobject kobj;
  17. struct net_device *dev;
  18. netdevice_tracker dev_tracker;
  19. #ifdef CONFIG_XDP_SOCKETS
  20. struct xsk_buff_pool *pool;
  21. #endif
  22. /* NAPI instance for the queue
  23. * Readers and writers must hold RTNL
  24. */
  25. struct napi_struct *napi;
  26. struct pp_memory_provider_params mp_params;
  27. } ____cacheline_aligned_in_smp;
  28. /*
  29. * RX queue sysfs structures and functions.
  30. */
  31. struct rx_queue_attribute {
  32. struct attribute attr;
  33. ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
  34. ssize_t (*store)(struct netdev_rx_queue *queue,
  35. const char *buf, size_t len);
  36. };
  37. static inline struct netdev_rx_queue *
  38. __netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
  39. {
  40. return dev->_rx + rxq;
  41. }
  42. static inline unsigned int
  43. get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
  44. {
  45. struct net_device *dev = queue->dev;
  46. int index = queue - dev->_rx;
  47. BUG_ON(index >= dev->num_rx_queues);
  48. return index;
  49. }
  50. int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
  51. #endif