MoonGen
 All Files Functions Variables Pages
filter_i40e.lua
Go to the documentation of this file.
1 ---------------------------------
2 --- @file filter_i40e.lua
3 --- @brief Filter for I40E ...
4 --- @todo TODO docu
5 ---------------------------------
6 
7 local mod = {}
8 
9 local dpdkc = require "dpdkc"
10 local device = require "device"
11 local ffi = require "ffi"
12 local dpdk = require "dpdk"
13 local dpdkc = require "dpdkc"
14 
15 ffi.cdef[[
16 enum i40e_status_code {
17  I40E_SUCCESS = 0,
18  I40E_ERR_NVM = -1,
19  I40E_ERR_NVM_CHECKSUM = -2,
20  I40E_ERR_PHY = -3,
21  I40E_ERR_CONFIG = -4,
22  I40E_ERR_PARAM = -5,
23  I40E_ERR_MAC_TYPE = -6,
24  I40E_ERR_UNKNOWN_PHY = -7,
25  I40E_ERR_LINK_SETUP = -8,
26  I40E_ERR_ADAPTER_STOPPED = -9,
27  I40E_ERR_INVALID_MAC_ADDR = -10,
28  I40E_ERR_DEVICE_NOT_SUPPORTED = -11,
29  I40E_ERR_MASTER_REQUESTS_PENDING = -12,
30  I40E_ERR_INVALID_LINK_SETTINGS = -13,
31  I40E_ERR_AUTONEG_NOT_COMPLETE = -14,
32  I40E_ERR_RESET_FAILED = -15,
33  I40E_ERR_SWFW_SYNC = -16,
34  I40E_ERR_NO_AVAILABLE_VSI = -17,
35  I40E_ERR_NO_MEMORY = -18,
36  I40E_ERR_BAD_PTR = -19,
37  I40E_ERR_RING_FULL = -20,
38  I40E_ERR_INVALID_PD_ID = -21,
39  I40E_ERR_INVALID_QP_ID = -22,
40  I40E_ERR_INVALID_CQ_ID = -23,
41  I40E_ERR_INVALID_CEQ_ID = -24,
42  I40E_ERR_INVALID_AEQ_ID = -25,
43  I40E_ERR_INVALID_SIZE = -26,
44  I40E_ERR_INVALID_ARP_INDEX = -27,
45  I40E_ERR_INVALID_FPM_FUNC_ID = -28,
46  I40E_ERR_QP_INVALID_MSG_SIZE = -29,
47  I40E_ERR_QP_TOOMANY_WRS_POSTED = -30,
48  I40E_ERR_INVALID_FRAG_COUNT = -31,
49  I40E_ERR_QUEUE_EMPTY = -32,
50  I40E_ERR_INVALID_ALIGNMENT = -33,
51  I40E_ERR_FLUSHED_QUEUE = -34,
52  I40E_ERR_INVALID_PUSH_PAGE_INDEX = -35,
53  I40E_ERR_INVALID_IMM_DATA_SIZE = -36,
54  I40E_ERR_TIMEOUT = -37,
55  I40E_ERR_OPCODE_MISMATCH = -38,
56  I40E_ERR_CQP_COMPL_ERROR = -39,
57  I40E_ERR_INVALID_VF_ID = -40,
58  I40E_ERR_INVALID_HMCFN_ID = -41,
59  I40E_ERR_BACKING_PAGE_ERROR = -42,
60  I40E_ERR_NO_PBLCHUNKS_AVAILABLE = -43,
61  I40E_ERR_INVALID_PBLE_INDEX = -44,
62  I40E_ERR_INVALID_SD_INDEX = -45,
63  I40E_ERR_INVALID_PAGE_DESC_INDEX = -46,
64  I40E_ERR_INVALID_SD_TYPE = -47,
65  I40E_ERR_MEMCPY_FAILED = -48,
66  I40E_ERR_INVALID_HMC_OBJ_INDEX = -49,
67  I40E_ERR_INVALID_HMC_OBJ_COUNT = -50,
68  I40E_ERR_INVALID_SRQ_ARM_LIMIT = -51,
69  I40E_ERR_SRQ_ENABLED = -52,
70  I40E_ERR_ADMIN_QUEUE_ERROR = -53,
71  I40E_ERR_ADMIN_QUEUE_TIMEOUT = -54,
72  I40E_ERR_BUF_TOO_SHORT = -55,
73  I40E_ERR_ADMIN_QUEUE_FULL = -56,
74  I40E_ERR_ADMIN_QUEUE_NO_WORK = -57,
75  I40E_ERR_BAD_IWARP_CQE = -58,
76  I40E_ERR_NVM_BLANK_MODE = -59,
77  I40E_ERR_NOT_IMPLEMENTED = -60,
78  I40E_ERR_PE_DOORBELL_NOT_ENABLED = -61,
79  I40E_ERR_DIAG_TEST_FAILED = -62,
80  I40E_ERR_NOT_READY = -63,
81  I40E_NOT_SUPPORTED = -64,
82  I40E_ERR_FIRMWARE_API_VERSION = -65,
83 };
84 
85 struct i40e_control_filter_stats {
86  uint16_t mac_etype_used; /* Used perfect match MAC/EtherType filters */
87  uint16_t etype_used; /* Used perfect EtherType filters */
88  uint16_t mac_etype_free; /* Un-used perfect match MAC/EtherType filters */
89  uint16_t etype_free; /* Un-used perfect EtherType filters */
90 };
91 
92 enum i40e_status_code i40e_aq_add_rem_control_packet_filter(void *hw,
93  uint8_t *mac_addr, uint16_t ethtype, uint16_t flags,
94  uint16_t vsi_seid, uint16_t queue, bool is_add,
95  struct i40e_control_filter_stats *stats,
96  struct i40e_asq_cmd_details *cmd_details);
97 ]]
98 
99 local C = ffi.C
100 
101 -- FIXME: use DPDK 2.0 filters here
102 function mod.l2Filter(dev, etype, queue)
103  if queue == -1 then
104  queue = 511
105  end
106  local i40eDev = dpdkc.get_i40e_dev(dev.id)
107  local vsiSeid = dpdkc.get_i40e_vsi_seid(dev.id)
108  assert(C.i40e_aq_add_rem_control_packet_filter(i40eDev, nil, etype, 1 + 4, vsiSeid, queue, true, null, null) == 0)
109 end
110 
111 return mod
local ffi
low-level dpdk wrapper
Definition: dpdkc.lua:6
local mod
high-level dpdk wrapper
Definition: dpdk.lua:6