xsk.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2019 Intel Corporation. */
  3. #ifndef XSK_H_
  4. #define XSK_H_
  5. /* Masks for xdp_umem_page flags.
  6. * The low 12-bits of the addr will be 0 since this is the page address, so we
  7. * can use them for flags.
  8. */
  9. #define XSK_NEXT_PG_CONTIG_SHIFT 0
  10. #define XSK_NEXT_PG_CONTIG_MASK BIT_ULL(XSK_NEXT_PG_CONTIG_SHIFT)
  11. struct xdp_ring_offset_v1 {
  12. __u64 producer;
  13. __u64 consumer;
  14. __u64 desc;
  15. };
  16. struct xdp_mmap_offsets_v1 {
  17. struct xdp_ring_offset_v1 rx;
  18. struct xdp_ring_offset_v1 tx;
  19. struct xdp_ring_offset_v1 fr;
  20. struct xdp_ring_offset_v1 cr;
  21. };
  22. /* Nodes are linked in the struct xdp_sock map_list field, and used to
  23. * track which maps a certain socket reside in.
  24. */
  25. struct xsk_map_node {
  26. struct list_head node;
  27. struct xsk_map *map;
  28. struct xdp_sock __rcu **map_entry;
  29. };
  30. static inline struct xdp_sock *xdp_sk(struct sock *sk)
  31. {
  32. return (struct xdp_sock *)sk;
  33. }
  34. void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
  35. struct xdp_sock __rcu **map_entry);
  36. void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id);
  37. int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,
  38. u16 queue_id);
  39. #endif /* XSK_H_ */