netdev_rx_queue.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include <net/netdev_queues.h>
  10. /* This structure contains an instance of an RX queue. */
  11. struct netdev_rx_queue {
  12. struct xdp_rxq_info xdp_rxq;
  13. #ifdef CONFIG_RPS
  14. struct rps_map __rcu *rps_map;
  15. struct rps_dev_flow_table __rcu *rps_flow_table;
  16. #endif
  17. struct kobject kobj;
  18. const struct attribute_group **groups;
  19. struct net_device *dev;
  20. netdevice_tracker dev_tracker;
  21. /* All fields below are "ops protected",
  22. * see comment about net_device::lock
  23. */
  24. #ifdef CONFIG_XDP_SOCKETS
  25. struct xsk_buff_pool *pool;
  26. #endif
  27. struct napi_struct *napi;
  28. struct netdev_queue_config qcfg;
  29. struct pp_memory_provider_params mp_params;
  30. } ____cacheline_aligned_in_smp;
  31. /*
  32. * RX queue sysfs structures and functions.
  33. */
  34. struct rx_queue_attribute {
  35. struct attribute attr;
  36. ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
  37. ssize_t (*store)(struct netdev_rx_queue *queue,
  38. const char *buf, size_t len);
  39. };
  40. static inline struct netdev_rx_queue *
  41. __netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
  42. {
  43. return dev->_rx + rxq;
  44. }
  45. static inline unsigned int
  46. get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
  47. {
  48. struct net_device *dev = queue->dev;
  49. int index = queue - dev->_rx;
  50. BUG_ON(index >= dev->num_rx_queues);
  51. return index;
  52. }
  53. int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
  54. #endif