ef100_rep.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2019 Solarflare Communications Inc.
  5. * Copyright 2020-2022 Xilinx Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation, incorporated herein by reference.
  10. */
  11. /* Handling for ef100 representor netdevs */
  12. #ifndef EF100_REP_H
  13. #define EF100_REP_H
  14. #include "net_driver.h"
  15. #include "tc.h"
  16. struct efx_rep_sw_stats {
  17. atomic64_t rx_packets, tx_packets;
  18. atomic64_t rx_bytes, tx_bytes;
  19. atomic64_t rx_dropped, tx_errors;
  20. };
  21. struct devlink_port;
  22. /**
  23. * struct efx_rep - Private data for an Efx representor
  24. *
  25. * @parent: the efx PF which manages this representor
  26. * @net_dev: representor netdevice
  27. * @msg_enable: log message enable flags
  28. * @mport: m-port ID of corresponding VF
  29. * @idx: VF index
  30. * @write_index: number of packets enqueued to @rx_list
  31. * @read_index: number of packets consumed from @rx_list
  32. * @rx_pring_size: max length of RX list
  33. * @dflt: default-rule for MAE switching
  34. * @list: entry on efx->vf_reps
  35. * @rx_list: list of SKBs queued for receive in NAPI poll
  36. * @rx_lock: protects @rx_list
  37. * @napi: NAPI control structure
  38. * @stats: software traffic counters for netdev stats
  39. * @dl_port: devlink port associated to this netdev representor
  40. */
  41. struct efx_rep {
  42. struct efx_nic *parent;
  43. struct net_device *net_dev;
  44. u32 msg_enable;
  45. u32 mport;
  46. unsigned int idx;
  47. unsigned int write_index, read_index;
  48. unsigned int rx_pring_size;
  49. struct efx_tc_flow_rule dflt;
  50. struct list_head list;
  51. struct list_head rx_list;
  52. spinlock_t rx_lock;
  53. struct napi_struct napi;
  54. struct efx_rep_sw_stats stats;
  55. struct devlink_port *dl_port;
  56. };
  57. int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i);
  58. void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv);
  59. void efx_ef100_fini_vfreps(struct efx_nic *efx);
  60. void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf);
  61. /* Returns the representor corresponding to a VF m-port, or NULL
  62. * @mport is an m-port label, *not* an m-port ID!
  63. * Caller must hold rcu_read_lock().
  64. */
  65. struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport);
  66. extern const struct net_device_ops efx_ef100_rep_netdev_ops;
  67. void efx_ef100_init_reps(struct efx_nic *efx);
  68. void efx_ef100_fini_reps(struct efx_nic *efx);
  69. struct mae_mport_desc;
  70. bool ef100_mport_on_local_intf(struct efx_nic *efx,
  71. struct mae_mport_desc *mport_desc);
  72. bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc);
  73. #endif /* EF100_REP_H */