1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
12 static __checkReturn efx_rc_t
13 efx_mae_get_capabilities(
17 EFX_MCDI_DECLARE_BUF(payload,
18 MC_CMD_MAE_GET_CAPS_IN_LEN,
19 MC_CMD_MAE_GET_CAPS_OUT_LEN);
20 struct efx_mae_s *maep = enp->en_maep;
23 req.emr_cmd = MC_CMD_MAE_GET_CAPS;
24 req.emr_in_buf = payload;
25 req.emr_in_length = MC_CMD_MAE_GET_CAPS_IN_LEN;
26 req.emr_out_buf = payload;
27 req.emr_out_length = MC_CMD_MAE_GET_CAPS_OUT_LEN;
29 efx_mcdi_execute(enp, &req);
31 if (req.emr_rc != 0) {
36 if (req.emr_out_length_used < MC_CMD_MAE_GET_CAPS_OUT_LEN) {
41 maep->em_max_n_outer_prios =
42 MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_OUTER_PRIOS);
44 maep->em_max_n_action_prios =
45 MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_ACTION_PRIOS);
47 maep->em_encap_types_supported = 0;
49 if (MCDI_OUT_DWORD_FIELD(req, MAE_GET_CAPS_OUT_ENCAP_TYPES_SUPPORTED,
50 MAE_GET_CAPS_OUT_ENCAP_TYPE_VXLAN) != 0) {
51 maep->em_encap_types_supported |=
52 (1U << EFX_TUNNEL_PROTOCOL_VXLAN);
55 if (MCDI_OUT_DWORD_FIELD(req, MAE_GET_CAPS_OUT_ENCAP_TYPES_SUPPORTED,
56 MAE_GET_CAPS_OUT_ENCAP_TYPE_GENEVE) != 0) {
57 maep->em_encap_types_supported |=
58 (1U << EFX_TUNNEL_PROTOCOL_GENEVE);
61 if (MCDI_OUT_DWORD_FIELD(req, MAE_GET_CAPS_OUT_ENCAP_TYPES_SUPPORTED,
62 MAE_GET_CAPS_OUT_ENCAP_TYPE_NVGRE) != 0) {
63 maep->em_encap_types_supported |=
64 (1U << EFX_TUNNEL_PROTOCOL_NVGRE);
67 maep->em_max_nfields =
68 MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_MATCH_FIELD_COUNT);
70 maep->em_max_ncounters =
71 MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_COUNTERS);
78 EFSYS_PROBE1(fail1, efx_rc_t, rc);
82 static __checkReturn efx_rc_t
83 efx_mae_get_outer_rule_caps(
85 __in unsigned int field_ncaps,
86 __out_ecount(field_ncaps) efx_mae_field_cap_t *field_caps)
89 EFX_MCDI_DECLARE_BUF(payload,
90 MC_CMD_MAE_GET_OR_CAPS_IN_LEN,
91 MC_CMD_MAE_GET_OR_CAPS_OUT_LENMAX_MCDI2);
92 unsigned int mcdi_field_ncaps;
96 if (MC_CMD_MAE_GET_OR_CAPS_OUT_LEN(field_ncaps) >
97 MC_CMD_MAE_GET_OR_CAPS_OUT_LENMAX_MCDI2) {
102 req.emr_cmd = MC_CMD_MAE_GET_OR_CAPS;
103 req.emr_in_buf = payload;
104 req.emr_in_length = MC_CMD_MAE_GET_OR_CAPS_IN_LEN;
105 req.emr_out_buf = payload;
106 req.emr_out_length = MC_CMD_MAE_GET_OR_CAPS_OUT_LEN(field_ncaps);
108 efx_mcdi_execute(enp, &req);
110 if (req.emr_rc != 0) {
115 if (req.emr_out_length_used < MC_CMD_MAE_GET_OR_CAPS_OUT_LENMIN) {
120 mcdi_field_ncaps = MCDI_OUT_DWORD(req, MAE_GET_OR_CAPS_OUT_COUNT);
122 if (req.emr_out_length_used <
123 MC_CMD_MAE_GET_OR_CAPS_OUT_LEN(mcdi_field_ncaps)) {
128 if (mcdi_field_ncaps > field_ncaps) {
133 for (i = 0; i < mcdi_field_ncaps; ++i) {
137 field_caps[i].emfc_support = MCDI_OUT_INDEXED_DWORD_FIELD(req,
138 MAE_GET_OR_CAPS_OUT_FIELD_FLAGS, i,
139 MAE_FIELD_FLAGS_SUPPORT_STATUS);
141 match_flag = MCDI_OUT_INDEXED_DWORD_FIELD(req,
142 MAE_GET_OR_CAPS_OUT_FIELD_FLAGS, i,
143 MAE_FIELD_FLAGS_MATCH_AFFECTS_CLASS);
145 field_caps[i].emfc_match_affects_class =
146 (match_flag != 0) ? B_TRUE : B_FALSE;
148 mask_flag = MCDI_OUT_INDEXED_DWORD_FIELD(req,
149 MAE_GET_OR_CAPS_OUT_FIELD_FLAGS, i,
150 MAE_FIELD_FLAGS_MASK_AFFECTS_CLASS);
152 field_caps[i].emfc_mask_affects_class =
153 (mask_flag != 0) ? B_TRUE : B_FALSE;
167 EFSYS_PROBE1(fail1, efx_rc_t, rc);
171 static __checkReturn efx_rc_t
172 efx_mae_get_action_rule_caps(
174 __in unsigned int field_ncaps,
175 __out_ecount(field_ncaps) efx_mae_field_cap_t *field_caps)
178 EFX_MCDI_DECLARE_BUF(payload,
179 MC_CMD_MAE_GET_AR_CAPS_IN_LEN,
180 MC_CMD_MAE_GET_AR_CAPS_OUT_LENMAX_MCDI2);
181 unsigned int mcdi_field_ncaps;
185 if (MC_CMD_MAE_GET_AR_CAPS_OUT_LEN(field_ncaps) >
186 MC_CMD_MAE_GET_AR_CAPS_OUT_LENMAX_MCDI2) {
191 req.emr_cmd = MC_CMD_MAE_GET_AR_CAPS;
192 req.emr_in_buf = payload;
193 req.emr_in_length = MC_CMD_MAE_GET_AR_CAPS_IN_LEN;
194 req.emr_out_buf = payload;
195 req.emr_out_length = MC_CMD_MAE_GET_AR_CAPS_OUT_LEN(field_ncaps);
197 efx_mcdi_execute(enp, &req);
199 if (req.emr_rc != 0) {
204 if (req.emr_out_length_used < MC_CMD_MAE_GET_AR_CAPS_OUT_LENMIN) {
209 mcdi_field_ncaps = MCDI_OUT_DWORD(req, MAE_GET_AR_CAPS_OUT_COUNT);
211 if (req.emr_out_length_used <
212 MC_CMD_MAE_GET_AR_CAPS_OUT_LEN(mcdi_field_ncaps)) {
217 if (mcdi_field_ncaps > field_ncaps) {
222 for (i = 0; i < mcdi_field_ncaps; ++i) {
226 field_caps[i].emfc_support = MCDI_OUT_INDEXED_DWORD_FIELD(req,
227 MAE_GET_AR_CAPS_OUT_FIELD_FLAGS, i,
228 MAE_FIELD_FLAGS_SUPPORT_STATUS);
230 match_flag = MCDI_OUT_INDEXED_DWORD_FIELD(req,
231 MAE_GET_AR_CAPS_OUT_FIELD_FLAGS, i,
232 MAE_FIELD_FLAGS_MATCH_AFFECTS_CLASS);
234 field_caps[i].emfc_match_affects_class =
235 (match_flag != 0) ? B_TRUE : B_FALSE;
237 mask_flag = MCDI_OUT_INDEXED_DWORD_FIELD(req,
238 MAE_GET_AR_CAPS_OUT_FIELD_FLAGS, i,
239 MAE_FIELD_FLAGS_MASK_AFFECTS_CLASS);
241 field_caps[i].emfc_mask_affects_class =
242 (mask_flag != 0) ? B_TRUE : B_FALSE;
256 EFSYS_PROBE1(fail1, efx_rc_t, rc);
260 __checkReturn efx_rc_t
264 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
265 efx_mae_field_cap_t *or_fcaps;
266 size_t or_fcaps_size;
267 efx_mae_field_cap_t *ar_fcaps;
268 size_t ar_fcaps_size;
272 if (encp->enc_mae_supported == B_FALSE) {
277 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*maep), maep);
285 rc = efx_mae_get_capabilities(enp);
289 or_fcaps_size = maep->em_max_nfields * sizeof (*or_fcaps);
290 EFSYS_KMEM_ALLOC(enp->en_esip, or_fcaps_size, or_fcaps);
291 if (or_fcaps == NULL) {
296 maep->em_outer_rule_field_caps_size = or_fcaps_size;
297 maep->em_outer_rule_field_caps = or_fcaps;
299 rc = efx_mae_get_outer_rule_caps(enp, maep->em_max_nfields, or_fcaps);
303 ar_fcaps_size = maep->em_max_nfields * sizeof (*ar_fcaps);
304 EFSYS_KMEM_ALLOC(enp->en_esip, ar_fcaps_size, ar_fcaps);
305 if (ar_fcaps == NULL) {
310 maep->em_action_rule_field_caps_size = ar_fcaps_size;
311 maep->em_action_rule_field_caps = ar_fcaps;
313 rc = efx_mae_get_action_rule_caps(enp, maep->em_max_nfields, ar_fcaps);
321 EFSYS_KMEM_FREE(enp->en_esip, ar_fcaps_size, ar_fcaps);
326 EFSYS_KMEM_FREE(enp->en_esip, or_fcaps_size, or_fcaps);
331 EFSYS_KMEM_FREE(enp->en_esip, sizeof (struct efx_mae_s), enp->en_maep);
336 EFSYS_PROBE1(fail1, efx_rc_t, rc);
344 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
345 efx_mae_t *maep = enp->en_maep;
347 if (encp->enc_mae_supported == B_FALSE)
350 EFSYS_KMEM_FREE(enp->en_esip, maep->em_action_rule_field_caps_size,
351 maep->em_action_rule_field_caps);
352 EFSYS_KMEM_FREE(enp->en_esip, maep->em_outer_rule_field_caps_size,
353 maep->em_outer_rule_field_caps);
354 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*maep), maep);
358 __checkReturn efx_rc_t
361 __out efx_mae_limits_t *emlp)
363 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
364 struct efx_mae_s *maep = enp->en_maep;
367 if (encp->enc_mae_supported == B_FALSE) {
372 emlp->eml_max_n_outer_prios = maep->em_max_n_outer_prios;
373 emlp->eml_max_n_action_prios = maep->em_max_n_action_prios;
374 emlp->eml_encap_types_supported = maep->em_encap_types_supported;
375 emlp->eml_encap_header_size_limit =
376 MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2;
381 EFSYS_PROBE1(fail1, efx_rc_t, rc);
385 __checkReturn efx_rc_t
386 efx_mae_match_spec_init(
388 __in efx_mae_rule_type_t type,
390 __out efx_mae_match_spec_t **specp)
392 efx_mae_match_spec_t *spec;
396 case EFX_MAE_RULE_OUTER:
398 case EFX_MAE_RULE_ACTION:
405 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), spec);
411 spec->emms_type = type;
412 spec->emms_prio = prio;
421 EFSYS_PROBE1(fail1, efx_rc_t, rc);
426 efx_mae_match_spec_fini(
428 __in efx_mae_match_spec_t *spec)
430 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec);
433 /* Named identifiers which are valid indices to efx_mae_field_cap_t */
434 typedef enum efx_mae_field_cap_id_e {
435 EFX_MAE_FIELD_ID_INGRESS_MPORT_SELECTOR = MAE_FIELD_INGRESS_PORT,
436 EFX_MAE_FIELD_ID_ETHER_TYPE_BE = MAE_FIELD_ETHER_TYPE,
437 EFX_MAE_FIELD_ID_ETH_SADDR_BE = MAE_FIELD_ETH_SADDR,
438 EFX_MAE_FIELD_ID_ETH_DADDR_BE = MAE_FIELD_ETH_DADDR,
439 EFX_MAE_FIELD_ID_VLAN0_TCI_BE = MAE_FIELD_VLAN0_TCI,
440 EFX_MAE_FIELD_ID_VLAN0_PROTO_BE = MAE_FIELD_VLAN0_PROTO,
441 EFX_MAE_FIELD_ID_VLAN1_TCI_BE = MAE_FIELD_VLAN1_TCI,
442 EFX_MAE_FIELD_ID_VLAN1_PROTO_BE = MAE_FIELD_VLAN1_PROTO,
443 EFX_MAE_FIELD_ID_SRC_IP4_BE = MAE_FIELD_SRC_IP4,
444 EFX_MAE_FIELD_ID_DST_IP4_BE = MAE_FIELD_DST_IP4,
445 EFX_MAE_FIELD_ID_IP_PROTO = MAE_FIELD_IP_PROTO,
446 EFX_MAE_FIELD_ID_IP_TOS = MAE_FIELD_IP_TOS,
447 EFX_MAE_FIELD_ID_IP_TTL = MAE_FIELD_IP_TTL,
448 EFX_MAE_FIELD_ID_SRC_IP6_BE = MAE_FIELD_SRC_IP6,
449 EFX_MAE_FIELD_ID_DST_IP6_BE = MAE_FIELD_DST_IP6,
450 EFX_MAE_FIELD_ID_L4_SPORT_BE = MAE_FIELD_L4_SPORT,
451 EFX_MAE_FIELD_ID_L4_DPORT_BE = MAE_FIELD_L4_DPORT,
452 EFX_MAE_FIELD_ID_TCP_FLAGS_BE = MAE_FIELD_TCP_FLAGS,
453 EFX_MAE_FIELD_ID_ENC_ETHER_TYPE_BE = MAE_FIELD_ENC_ETHER_TYPE,
454 EFX_MAE_FIELD_ID_ENC_ETH_SADDR_BE = MAE_FIELD_ENC_ETH_SADDR,
455 EFX_MAE_FIELD_ID_ENC_ETH_DADDR_BE = MAE_FIELD_ENC_ETH_DADDR,
456 EFX_MAE_FIELD_ID_ENC_VLAN0_TCI_BE = MAE_FIELD_ENC_VLAN0_TCI,
457 EFX_MAE_FIELD_ID_ENC_VLAN0_PROTO_BE = MAE_FIELD_ENC_VLAN0_PROTO,
458 EFX_MAE_FIELD_ID_ENC_VLAN1_TCI_BE = MAE_FIELD_ENC_VLAN1_TCI,
459 EFX_MAE_FIELD_ID_ENC_VLAN1_PROTO_BE = MAE_FIELD_ENC_VLAN1_PROTO,
460 EFX_MAE_FIELD_ID_ENC_SRC_IP4_BE = MAE_FIELD_ENC_SRC_IP4,
461 EFX_MAE_FIELD_ID_ENC_DST_IP4_BE = MAE_FIELD_ENC_DST_IP4,
462 EFX_MAE_FIELD_ID_ENC_IP_PROTO = MAE_FIELD_ENC_IP_PROTO,
463 EFX_MAE_FIELD_ID_ENC_IP_TOS = MAE_FIELD_ENC_IP_TOS,
464 EFX_MAE_FIELD_ID_ENC_IP_TTL = MAE_FIELD_ENC_IP_TTL,
465 EFX_MAE_FIELD_ID_ENC_SRC_IP6_BE = MAE_FIELD_ENC_SRC_IP6,
466 EFX_MAE_FIELD_ID_ENC_DST_IP6_BE = MAE_FIELD_ENC_DST_IP6,
467 EFX_MAE_FIELD_ID_ENC_L4_SPORT_BE = MAE_FIELD_ENC_L4_SPORT,
468 EFX_MAE_FIELD_ID_ENC_L4_DPORT_BE = MAE_FIELD_ENC_L4_DPORT,
469 EFX_MAE_FIELD_ID_ENC_VNET_ID_BE = MAE_FIELD_ENC_VNET_ID,
470 EFX_MAE_FIELD_ID_OUTER_RULE_ID = MAE_FIELD_OUTER_RULE_ID,
471 EFX_MAE_FIELD_ID_HAS_OVLAN = MAE_FIELD_HAS_OVLAN,
472 EFX_MAE_FIELD_ID_HAS_IVLAN = MAE_FIELD_HAS_IVLAN,
473 EFX_MAE_FIELD_ID_ENC_HAS_OVLAN = MAE_FIELD_ENC_HAS_OVLAN,
474 EFX_MAE_FIELD_ID_ENC_HAS_IVLAN = MAE_FIELD_ENC_HAS_IVLAN,
476 EFX_MAE_FIELD_CAP_NIDS
477 } efx_mae_field_cap_id_t;
479 typedef enum efx_mae_field_endianness_e {
480 EFX_MAE_FIELD_LE = 0,
483 EFX_MAE_FIELD_ENDIANNESS_NTYPES
484 } efx_mae_field_endianness_t;
487 * The following structure is a means to describe an MAE field.
488 * The information in it is meant to be used internally by
489 * APIs for addressing a given field in a mask-value pairs
490 * structure and for validation purposes.
492 * A field may have an alternative one. This structure
493 * has additional members to reference the alternative
494 * field's mask. See efx_mae_match_spec_is_valid().
496 typedef struct efx_mae_mv_desc_s {
497 efx_mae_field_cap_id_t emmd_field_cap_id;
499 size_t emmd_value_size;
500 size_t emmd_value_offset;
501 size_t emmd_mask_size;
502 size_t emmd_mask_offset;
505 * Having the alternative field's mask size set to 0
506 * means that there's no alternative field specified.
508 size_t emmd_alt_mask_size;
509 size_t emmd_alt_mask_offset;
511 /* Primary field and the alternative one are of the same endianness. */
512 efx_mae_field_endianness_t emmd_endianness;
515 /* Indices to this array are provided by efx_mae_field_id_t */
516 static const efx_mae_mv_desc_t __efx_mae_action_rule_mv_desc_set[] = {
517 #define EFX_MAE_MV_DESC(_name, _endianness) \
518 [EFX_MAE_FIELD_##_name] = \
520 EFX_MAE_FIELD_ID_##_name, \
521 MAE_FIELD_MASK_VALUE_PAIRS_##_name##_LEN, \
522 MAE_FIELD_MASK_VALUE_PAIRS_##_name##_OFST, \
523 MAE_FIELD_MASK_VALUE_PAIRS_##_name##_MASK_LEN, \
524 MAE_FIELD_MASK_VALUE_PAIRS_##_name##_MASK_OFST, \
525 0, 0 /* no alternative field */, \
529 EFX_MAE_MV_DESC(INGRESS_MPORT_SELECTOR, EFX_MAE_FIELD_LE),
530 EFX_MAE_MV_DESC(ETHER_TYPE_BE, EFX_MAE_FIELD_BE),
531 EFX_MAE_MV_DESC(ETH_SADDR_BE, EFX_MAE_FIELD_BE),
532 EFX_MAE_MV_DESC(ETH_DADDR_BE, EFX_MAE_FIELD_BE),
533 EFX_MAE_MV_DESC(VLAN0_TCI_BE, EFX_MAE_FIELD_BE),
534 EFX_MAE_MV_DESC(VLAN0_PROTO_BE, EFX_MAE_FIELD_BE),
535 EFX_MAE_MV_DESC(VLAN1_TCI_BE, EFX_MAE_FIELD_BE),
536 EFX_MAE_MV_DESC(VLAN1_PROTO_BE, EFX_MAE_FIELD_BE),
537 EFX_MAE_MV_DESC(SRC_IP4_BE, EFX_MAE_FIELD_BE),
538 EFX_MAE_MV_DESC(DST_IP4_BE, EFX_MAE_FIELD_BE),
539 EFX_MAE_MV_DESC(IP_PROTO, EFX_MAE_FIELD_BE),
540 EFX_MAE_MV_DESC(IP_TOS, EFX_MAE_FIELD_BE),
541 EFX_MAE_MV_DESC(IP_TTL, EFX_MAE_FIELD_BE),
542 EFX_MAE_MV_DESC(SRC_IP6_BE, EFX_MAE_FIELD_BE),
543 EFX_MAE_MV_DESC(DST_IP6_BE, EFX_MAE_FIELD_BE),
544 EFX_MAE_MV_DESC(L4_SPORT_BE, EFX_MAE_FIELD_BE),
545 EFX_MAE_MV_DESC(L4_DPORT_BE, EFX_MAE_FIELD_BE),
546 EFX_MAE_MV_DESC(TCP_FLAGS_BE, EFX_MAE_FIELD_BE),
547 EFX_MAE_MV_DESC(ENC_VNET_ID_BE, EFX_MAE_FIELD_BE),
548 EFX_MAE_MV_DESC(OUTER_RULE_ID, EFX_MAE_FIELD_LE),
550 #undef EFX_MAE_MV_DESC
553 /* Indices to this array are provided by efx_mae_field_id_t */
554 static const efx_mae_mv_desc_t __efx_mae_outer_rule_mv_desc_set[] = {
555 #define EFX_MAE_MV_DESC(_name, _endianness) \
556 [EFX_MAE_FIELD_##_name] = \
558 EFX_MAE_FIELD_ID_##_name, \
559 MAE_ENC_FIELD_PAIRS_##_name##_LEN, \
560 MAE_ENC_FIELD_PAIRS_##_name##_OFST, \
561 MAE_ENC_FIELD_PAIRS_##_name##_MASK_LEN, \
562 MAE_ENC_FIELD_PAIRS_##_name##_MASK_OFST, \
563 0, 0 /* no alternative field */, \
567 /* Same as EFX_MAE_MV_DESC(), but also indicates an alternative field. */
568 #define EFX_MAE_MV_DESC_ALT(_name, _alt_name, _endianness) \
569 [EFX_MAE_FIELD_##_name] = \
571 EFX_MAE_FIELD_ID_##_name, \
572 MAE_ENC_FIELD_PAIRS_##_name##_LEN, \
573 MAE_ENC_FIELD_PAIRS_##_name##_OFST, \
574 MAE_ENC_FIELD_PAIRS_##_name##_MASK_LEN, \
575 MAE_ENC_FIELD_PAIRS_##_name##_MASK_OFST, \
576 MAE_ENC_FIELD_PAIRS_##_alt_name##_MASK_LEN, \
577 MAE_ENC_FIELD_PAIRS_##_alt_name##_MASK_OFST, \
581 EFX_MAE_MV_DESC(INGRESS_MPORT_SELECTOR, EFX_MAE_FIELD_LE),
582 EFX_MAE_MV_DESC(ENC_ETHER_TYPE_BE, EFX_MAE_FIELD_BE),
583 EFX_MAE_MV_DESC(ENC_ETH_SADDR_BE, EFX_MAE_FIELD_BE),
584 EFX_MAE_MV_DESC(ENC_ETH_DADDR_BE, EFX_MAE_FIELD_BE),
585 EFX_MAE_MV_DESC(ENC_VLAN0_TCI_BE, EFX_MAE_FIELD_BE),
586 EFX_MAE_MV_DESC(ENC_VLAN0_PROTO_BE, EFX_MAE_FIELD_BE),
587 EFX_MAE_MV_DESC(ENC_VLAN1_TCI_BE, EFX_MAE_FIELD_BE),
588 EFX_MAE_MV_DESC(ENC_VLAN1_PROTO_BE, EFX_MAE_FIELD_BE),
589 EFX_MAE_MV_DESC_ALT(ENC_SRC_IP4_BE, ENC_SRC_IP6_BE, EFX_MAE_FIELD_BE),
590 EFX_MAE_MV_DESC_ALT(ENC_DST_IP4_BE, ENC_DST_IP6_BE, EFX_MAE_FIELD_BE),
591 EFX_MAE_MV_DESC(ENC_IP_PROTO, EFX_MAE_FIELD_BE),
592 EFX_MAE_MV_DESC(ENC_IP_TOS, EFX_MAE_FIELD_BE),
593 EFX_MAE_MV_DESC(ENC_IP_TTL, EFX_MAE_FIELD_BE),
594 EFX_MAE_MV_DESC_ALT(ENC_SRC_IP6_BE, ENC_SRC_IP4_BE, EFX_MAE_FIELD_BE),
595 EFX_MAE_MV_DESC_ALT(ENC_DST_IP6_BE, ENC_DST_IP4_BE, EFX_MAE_FIELD_BE),
596 EFX_MAE_MV_DESC(ENC_L4_SPORT_BE, EFX_MAE_FIELD_BE),
597 EFX_MAE_MV_DESC(ENC_L4_DPORT_BE, EFX_MAE_FIELD_BE),
599 #undef EFX_MAE_MV_DESC_ALT
600 #undef EFX_MAE_MV_DESC
604 * The following structure is a means to describe an MAE bit.
605 * The information in it is meant to be used internally by
606 * APIs for addressing a given flag in a mask-value pairs
607 * structure and for validation purposes.
609 typedef struct efx_mae_mv_bit_desc_s {
611 * Arrays using this struct are indexed by field IDs.
612 * Fields which aren't meant to be referenced by these
613 * arrays comprise gaps (invalid entries). Below field
614 * helps to identify such entries.
616 boolean_t emmbd_entry_is_valid;
617 efx_mae_field_cap_id_t emmbd_bit_cap_id;
618 size_t emmbd_value_ofst;
619 unsigned int emmbd_value_lbn;
620 size_t emmbd_mask_ofst;
621 unsigned int emmbd_mask_lbn;
622 } efx_mae_mv_bit_desc_t;
624 static const efx_mae_mv_bit_desc_t __efx_mae_outer_rule_mv_bit_desc_set[] = {
625 #define EFX_MAE_MV_BIT_DESC(_name) \
626 [EFX_MAE_FIELD_##_name] = \
629 EFX_MAE_FIELD_ID_##_name, \
630 MAE_ENC_FIELD_PAIRS_##_name##_OFST, \
631 MAE_ENC_FIELD_PAIRS_##_name##_LBN, \
632 MAE_ENC_FIELD_PAIRS_##_name##_MASK_OFST, \
633 MAE_ENC_FIELD_PAIRS_##_name##_MASK_LBN, \
636 EFX_MAE_MV_BIT_DESC(ENC_HAS_OVLAN),
637 EFX_MAE_MV_BIT_DESC(ENC_HAS_IVLAN),
639 #undef EFX_MAE_MV_BIT_DESC
642 static const efx_mae_mv_bit_desc_t __efx_mae_action_rule_mv_bit_desc_set[] = {
643 #define EFX_MAE_MV_BIT_DESC(_name) \
644 [EFX_MAE_FIELD_##_name] = \
647 EFX_MAE_FIELD_ID_##_name, \
648 MAE_FIELD_MASK_VALUE_PAIRS_V2_FLAGS_OFST, \
649 MAE_FIELD_MASK_VALUE_PAIRS_V2_##_name##_LBN, \
650 MAE_FIELD_MASK_VALUE_PAIRS_V2_FLAGS_MASK_OFST, \
651 MAE_FIELD_MASK_VALUE_PAIRS_V2_##_name##_LBN, \
654 EFX_MAE_MV_BIT_DESC(HAS_OVLAN),
655 EFX_MAE_MV_BIT_DESC(HAS_IVLAN),
656 EFX_MAE_MV_BIT_DESC(ENC_HAS_OVLAN),
657 EFX_MAE_MV_BIT_DESC(ENC_HAS_IVLAN),
659 #undef EFX_MAE_MV_BIT_DESC
662 __checkReturn efx_rc_t
663 efx_mae_mport_by_phy_port(
664 __in uint32_t phy_port,
665 __out efx_mport_sel_t *mportp)
670 if (phy_port > EFX_MASK32(MAE_MPORT_SELECTOR_PPORT_ID)) {
675 EFX_POPULATE_DWORD_2(dword,
676 MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_PPORT,
677 MAE_MPORT_SELECTOR_PPORT_ID, phy_port);
679 memset(mportp, 0, sizeof (*mportp));
681 * The constructed DWORD is little-endian,
682 * but the resulting value is meant to be
683 * passed to MCDIs, where it will undergo
684 * host-order to little endian conversion.
686 mportp->sel = EFX_DWORD_FIELD(dword, EFX_DWORD_0);
691 EFSYS_PROBE1(fail1, efx_rc_t, rc);
695 __checkReturn efx_rc_t
696 efx_mae_mport_by_pcie_function(
699 __out efx_mport_sel_t *mportp)
704 EFX_STATIC_ASSERT(EFX_PCI_VF_INVALID ==
705 MAE_MPORT_SELECTOR_FUNC_VF_ID_NULL);
707 if (pf > EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_PF_ID)) {
712 if (vf > EFX_MASK32(MAE_MPORT_SELECTOR_FUNC_VF_ID)) {
717 EFX_POPULATE_DWORD_3(dword,
718 MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_FUNC,
719 MAE_MPORT_SELECTOR_FUNC_PF_ID, pf,
720 MAE_MPORT_SELECTOR_FUNC_VF_ID, vf);
722 memset(mportp, 0, sizeof (*mportp));
724 * The constructed DWORD is little-endian,
725 * but the resulting value is meant to be
726 * passed to MCDIs, where it will undergo
727 * host-order to little endian conversion.
729 mportp->sel = EFX_DWORD_FIELD(dword, EFX_DWORD_0);
736 EFSYS_PROBE1(fail1, efx_rc_t, rc);
740 __checkReturn efx_rc_t
741 efx_mae_match_spec_field_set(
742 __in efx_mae_match_spec_t *spec,
743 __in efx_mae_field_id_t field_id,
744 __in size_t value_size,
745 __in_bcount(value_size) const uint8_t *value,
746 __in size_t mask_size,
747 __in_bcount(mask_size) const uint8_t *mask)
749 const efx_mae_mv_desc_t *descp;
750 unsigned int desc_set_nentries;
754 switch (spec->emms_type) {
755 case EFX_MAE_RULE_OUTER:
757 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_desc_set);
758 descp = &__efx_mae_outer_rule_mv_desc_set[field_id];
759 mvp = spec->emms_mask_value_pairs.outer;
761 case EFX_MAE_RULE_ACTION:
763 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_desc_set);
764 descp = &__efx_mae_action_rule_mv_desc_set[field_id];
765 mvp = spec->emms_mask_value_pairs.action;
772 if ((unsigned int)field_id >= desc_set_nentries) {
777 if (descp->emmd_mask_size == 0) {
778 /* The ID points to a gap in the array of field descriptors. */
783 if (value_size != descp->emmd_value_size) {
788 if (mask_size != descp->emmd_mask_size) {
793 if (descp->emmd_endianness == EFX_MAE_FIELD_BE) {
797 * The mask/value are in network (big endian) order.
798 * The MCDI request field is also big endian.
801 EFSYS_ASSERT3U(value_size, ==, mask_size);
803 for (i = 0; i < value_size; ++i) {
804 uint8_t *v_bytep = mvp + descp->emmd_value_offset + i;
805 uint8_t *m_bytep = mvp + descp->emmd_mask_offset + i;
808 * Apply the mask (which may be all-zeros) to the value.
810 * If this API is provided with some value to set for a
811 * given field in one specification and with some other
812 * value to set for this field in another specification,
813 * then, if the two masks are all-zeros, the field will
814 * avoid being counted as a mismatch when comparing the
815 * specifications using efx_mae_match_specs_equal() API.
817 *v_bytep = value[i] & mask[i];
824 * The mask/value are in host byte order.
825 * The MCDI request field is little endian.
827 switch (value_size) {
829 EFX_POPULATE_DWORD_1(dword,
830 EFX_DWORD_0, *(const uint32_t *)value);
832 memcpy(mvp + descp->emmd_value_offset,
833 &dword, sizeof (dword));
836 EFSYS_ASSERT(B_FALSE);
841 EFX_POPULATE_DWORD_1(dword,
842 EFX_DWORD_0, *(const uint32_t *)mask);
844 memcpy(mvp + descp->emmd_mask_offset,
845 &dword, sizeof (dword));
848 EFSYS_ASSERT(B_FALSE);
863 EFSYS_PROBE1(fail1, efx_rc_t, rc);
867 __checkReturn efx_rc_t
868 efx_mae_match_spec_bit_set(
869 __in efx_mae_match_spec_t *spec,
870 __in efx_mae_field_id_t field_id,
871 __in boolean_t value)
873 const efx_mae_mv_bit_desc_t *bit_descp;
874 unsigned int bit_desc_set_nentries;
875 unsigned int byte_idx;
876 unsigned int bit_idx;
880 switch (spec->emms_type) {
881 case EFX_MAE_RULE_OUTER:
882 bit_desc_set_nentries =
883 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_bit_desc_set);
884 bit_descp = &__efx_mae_outer_rule_mv_bit_desc_set[field_id];
885 mvp = spec->emms_mask_value_pairs.outer;
887 case EFX_MAE_RULE_ACTION:
888 bit_desc_set_nentries =
889 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_bit_desc_set);
890 bit_descp = &__efx_mae_action_rule_mv_bit_desc_set[field_id];
891 mvp = spec->emms_mask_value_pairs.action;
898 if ((unsigned int)field_id >= bit_desc_set_nentries) {
903 if (bit_descp->emmbd_entry_is_valid == B_FALSE) {
908 byte_idx = bit_descp->emmbd_value_ofst + bit_descp->emmbd_value_lbn / 8;
909 bit_idx = bit_descp->emmbd_value_lbn % 8;
911 if (value != B_FALSE)
912 mvp[byte_idx] |= (1U << bit_idx);
914 mvp[byte_idx] &= ~(1U << bit_idx);
916 byte_idx = bit_descp->emmbd_mask_ofst + bit_descp->emmbd_mask_lbn / 8;
917 bit_idx = bit_descp->emmbd_mask_lbn % 8;
918 mvp[byte_idx] |= (1U << bit_idx);
927 EFSYS_PROBE1(fail1, efx_rc_t, rc);
931 __checkReturn efx_rc_t
932 efx_mae_match_spec_mport_set(
933 __in efx_mae_match_spec_t *spec,
934 __in const efx_mport_sel_t *valuep,
935 __in_opt const efx_mport_sel_t *maskp)
937 uint32_t full_mask = UINT32_MAX;
942 if (valuep == NULL) {
947 vp = (const uint8_t *)&valuep->sel;
949 mp = (const uint8_t *)&maskp->sel;
951 mp = (const uint8_t *)&full_mask;
953 rc = efx_mae_match_spec_field_set(spec,
954 EFX_MAE_FIELD_INGRESS_MPORT_SELECTOR,
955 sizeof (valuep->sel), vp, sizeof (maskp->sel), mp);
964 EFSYS_PROBE1(fail1, efx_rc_t, rc);
968 __checkReturn boolean_t
969 efx_mae_match_specs_equal(
970 __in const efx_mae_match_spec_t *left,
971 __in const efx_mae_match_spec_t *right)
973 return ((memcmp(left, right, sizeof (*left)) == 0) ? B_TRUE : B_FALSE);
976 #define EFX_MASK_BIT_IS_SET(_mask, _mask_page_nbits, _bit) \
977 ((_mask)[(_bit) / (_mask_page_nbits)] & \
978 (1ULL << ((_bit) & ((_mask_page_nbits) - 1))))
982 __in size_t mask_nbytes,
983 __in_bcount(mask_nbytes) const uint8_t *maskp)
985 boolean_t prev_bit_is_set = B_TRUE;
988 for (i = 0; i < 8 * mask_nbytes; ++i) {
989 boolean_t bit_is_set = EFX_MASK_BIT_IS_SET(maskp, 8, i);
991 if (!prev_bit_is_set && bit_is_set)
994 prev_bit_is_set = bit_is_set;
1001 efx_mask_is_all_ones(
1002 __in size_t mask_nbytes,
1003 __in_bcount(mask_nbytes) const uint8_t *maskp)
1008 for (i = 0; i < mask_nbytes; ++i)
1011 return (t == (uint8_t)(~0));
1015 efx_mask_is_all_zeros(
1016 __in size_t mask_nbytes,
1017 __in_bcount(mask_nbytes) const uint8_t *maskp)
1022 for (i = 0; i < mask_nbytes; ++i)
1028 __checkReturn boolean_t
1029 efx_mae_match_spec_is_valid(
1030 __in efx_nic_t *enp,
1031 __in const efx_mae_match_spec_t *spec)
1033 efx_mae_t *maep = enp->en_maep;
1034 unsigned int field_ncaps = maep->em_max_nfields;
1035 const efx_mae_field_cap_t *field_caps;
1036 const efx_mae_mv_desc_t *desc_setp;
1037 unsigned int desc_set_nentries;
1038 const efx_mae_mv_bit_desc_t *bit_desc_setp;
1039 unsigned int bit_desc_set_nentries;
1040 boolean_t is_valid = B_TRUE;
1041 efx_mae_field_id_t field_id;
1044 switch (spec->emms_type) {
1045 case EFX_MAE_RULE_OUTER:
1046 field_caps = maep->em_outer_rule_field_caps;
1047 desc_setp = __efx_mae_outer_rule_mv_desc_set;
1049 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_desc_set);
1050 bit_desc_setp = __efx_mae_outer_rule_mv_bit_desc_set;
1051 bit_desc_set_nentries =
1052 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_bit_desc_set);
1053 mvp = spec->emms_mask_value_pairs.outer;
1055 case EFX_MAE_RULE_ACTION:
1056 field_caps = maep->em_action_rule_field_caps;
1057 desc_setp = __efx_mae_action_rule_mv_desc_set;
1059 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_desc_set);
1060 bit_desc_setp = __efx_mae_action_rule_mv_bit_desc_set;
1061 bit_desc_set_nentries =
1062 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_bit_desc_set);
1063 mvp = spec->emms_mask_value_pairs.action;
1069 if (field_caps == NULL)
1072 for (field_id = 0; (unsigned int)field_id < desc_set_nentries;
1074 const efx_mae_mv_desc_t *descp = &desc_setp[field_id];
1075 efx_mae_field_cap_id_t field_cap_id = descp->emmd_field_cap_id;
1076 const uint8_t *alt_m_buf = mvp + descp->emmd_alt_mask_offset;
1077 const uint8_t *m_buf = mvp + descp->emmd_mask_offset;
1078 size_t alt_m_size = descp->emmd_alt_mask_size;
1079 size_t m_size = descp->emmd_mask_size;
1082 continue; /* Skip array gap */
1084 if ((unsigned int)field_cap_id >= field_ncaps) {
1086 * The FW has not reported capability status for
1087 * this field. Make sure that its mask is zeroed.
1089 is_valid = efx_mask_is_all_zeros(m_size, m_buf);
1090 if (is_valid != B_FALSE)
1096 switch (field_caps[field_cap_id].emfc_support) {
1097 case MAE_FIELD_SUPPORTED_MATCH_MASK:
1100 case MAE_FIELD_SUPPORTED_MATCH_PREFIX:
1101 is_valid = efx_mask_is_prefix(m_size, m_buf);
1103 case MAE_FIELD_SUPPORTED_MATCH_OPTIONAL:
1104 is_valid = (efx_mask_is_all_ones(m_size, m_buf) ||
1105 efx_mask_is_all_zeros(m_size, m_buf));
1107 case MAE_FIELD_SUPPORTED_MATCH_ALWAYS:
1108 is_valid = efx_mask_is_all_ones(m_size, m_buf);
1110 if ((is_valid == B_FALSE) && (alt_m_size != 0)) {
1112 * This field has an alternative one. The FW
1113 * reports ALWAYS for both implying that one
1114 * of them is required to have all-ones mask.
1116 * The primary field's mask is incorrect; go
1117 * on to check that of the alternative field.
1119 is_valid = efx_mask_is_all_ones(alt_m_size,
1123 case MAE_FIELD_SUPPORTED_MATCH_NEVER:
1124 case MAE_FIELD_UNSUPPORTED:
1126 is_valid = efx_mask_is_all_zeros(m_size, m_buf);
1130 if (is_valid == B_FALSE)
1134 for (field_id = 0; (unsigned int)field_id < bit_desc_set_nentries;
1136 const efx_mae_mv_bit_desc_t *bit_descp =
1137 &bit_desc_setp[field_id];
1138 unsigned int byte_idx =
1139 bit_descp->emmbd_mask_ofst +
1140 bit_descp->emmbd_mask_lbn / 8;
1141 unsigned int bit_idx =
1142 bit_descp->emmbd_mask_lbn % 8;
1143 efx_mae_field_cap_id_t bit_cap_id =
1144 bit_descp->emmbd_bit_cap_id;
1146 if (bit_descp->emmbd_entry_is_valid == B_FALSE)
1147 continue; /* Skip array gap */
1149 if ((unsigned int)bit_cap_id >= field_ncaps) {
1150 /* No capability for this bit = unsupported. */
1151 is_valid = ((mvp[byte_idx] & (1U << bit_idx)) == 0);
1152 if (is_valid == B_FALSE)
1158 switch (field_caps[bit_cap_id].emfc_support) {
1159 case MAE_FIELD_SUPPORTED_MATCH_OPTIONAL:
1162 case MAE_FIELD_SUPPORTED_MATCH_ALWAYS:
1163 is_valid = ((mvp[byte_idx] & (1U << bit_idx)) != 0);
1165 case MAE_FIELD_SUPPORTED_MATCH_NEVER:
1166 case MAE_FIELD_UNSUPPORTED:
1168 is_valid = ((mvp[byte_idx] & (1U << bit_idx)) == 0);
1172 if (is_valid == B_FALSE)
1179 __checkReturn efx_rc_t
1180 efx_mae_action_set_spec_init(
1181 __in efx_nic_t *enp,
1182 __out efx_mae_actions_t **specp)
1184 efx_mae_actions_t *spec;
1187 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), spec);
1193 spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
1194 spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
1201 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1206 efx_mae_action_set_spec_fini(
1207 __in efx_nic_t *enp,
1208 __in efx_mae_actions_t *spec)
1210 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec);
1213 static __checkReturn efx_rc_t
1214 efx_mae_action_set_add_decap(
1215 __in efx_mae_actions_t *spec,
1216 __in size_t arg_size,
1217 __in_bcount(arg_size) const uint8_t *arg)
1221 _NOTE(ARGUNUSED(spec))
1223 if (arg_size != 0) {
1233 /* This action does not have any arguments, so do nothing here. */
1240 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1244 static __checkReturn efx_rc_t
1245 efx_mae_action_set_add_vlan_pop(
1246 __in efx_mae_actions_t *spec,
1247 __in size_t arg_size,
1248 __in_bcount(arg_size) const uint8_t *arg)
1252 if (arg_size != 0) {
1262 if (spec->ema_n_vlan_tags_to_pop == EFX_MAE_VLAN_POP_MAX_NTAGS) {
1267 ++spec->ema_n_vlan_tags_to_pop;
1276 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1280 static __checkReturn efx_rc_t
1281 efx_mae_action_set_add_vlan_push(
1282 __in efx_mae_actions_t *spec,
1283 __in size_t arg_size,
1284 __in_bcount(arg_size) const uint8_t *arg)
1286 unsigned int n_tags = spec->ema_n_vlan_tags_to_push;
1289 if (arg_size != sizeof (*spec->ema_vlan_push_descs)) {
1299 if (n_tags == EFX_MAE_VLAN_PUSH_MAX_NTAGS) {
1304 memcpy(&spec->ema_vlan_push_descs[n_tags], arg, arg_size);
1305 ++(spec->ema_n_vlan_tags_to_push);
1314 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1318 static __checkReturn efx_rc_t
1319 efx_mae_action_set_add_encap(
1320 __in efx_mae_actions_t *spec,
1321 __in size_t arg_size,
1322 __in_bcount(arg_size) const uint8_t *arg)
1327 * Adding this specific action to an action set spec and setting encap.
1328 * header ID in the spec are two individual steps. This design allows
1329 * the client driver to avoid encap. header allocation when it simply
1330 * needs to check the order of actions submitted by user ("validate"),
1331 * without actually allocating an action set and inserting a rule.
1333 * For now, mark encap. header ID as invalid; the caller will invoke
1334 * efx_mae_action_set_fill_in_eh_id() to override the field prior
1335 * to action set allocation; otherwise, the allocation will fail.
1337 spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
1340 * As explained above, there are no arguments to handle here.
1341 * efx_mae_action_set_fill_in_eh_id() will take care of them.
1343 if (arg_size != 0) {
1358 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1362 static __checkReturn efx_rc_t
1363 efx_mae_action_set_add_count(
1364 __in efx_mae_actions_t *spec,
1365 __in size_t arg_size,
1366 __in_bcount(arg_size) const uint8_t *arg)
1370 EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID ==
1371 MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_NULL);
1374 * Preparing an action set spec to update a counter requires
1375 * two steps: first add this action to the action spec, and then
1376 * add the counter ID to the spec. This allows validity checking
1377 * and resource allocation to be done separately.
1378 * Mark the counter ID as invalid in the spec to ensure that the
1379 * caller must also invoke efx_mae_action_set_fill_in_counter_id()
1380 * before action set allocation.
1382 spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
1384 /* Nothing else is supposed to take place over here. */
1385 if (arg_size != 0) {
1395 ++(spec->ema_n_count_actions);
1402 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1406 static __checkReturn efx_rc_t
1407 efx_mae_action_set_add_flag(
1408 __in efx_mae_actions_t *spec,
1409 __in size_t arg_size,
1410 __in_bcount(arg_size) const uint8_t *arg)
1414 _NOTE(ARGUNUSED(spec))
1416 if (arg_size != 0) {
1426 /* This action does not have any arguments, so do nothing here. */
1433 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1437 static __checkReturn efx_rc_t
1438 efx_mae_action_set_add_mark(
1439 __in efx_mae_actions_t *spec,
1440 __in size_t arg_size,
1441 __in_bcount(arg_size) const uint8_t *arg)
1445 if (arg_size != sizeof (spec->ema_mark_value)) {
1455 memcpy(&spec->ema_mark_value, arg, arg_size);
1462 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1466 static __checkReturn efx_rc_t
1467 efx_mae_action_set_add_deliver(
1468 __in efx_mae_actions_t *spec,
1469 __in size_t arg_size,
1470 __in_bcount(arg_size) const uint8_t *arg)
1474 if (arg_size != sizeof (spec->ema_deliver_mport)) {
1484 memcpy(&spec->ema_deliver_mport, arg, arg_size);
1491 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1495 typedef struct efx_mae_action_desc_s {
1496 /* Action specific handler */
1497 efx_rc_t (*emad_add)(efx_mae_actions_t *,
1498 size_t, const uint8_t *);
1499 } efx_mae_action_desc_t;
1501 static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
1502 [EFX_MAE_ACTION_DECAP] = {
1503 .emad_add = efx_mae_action_set_add_decap
1505 [EFX_MAE_ACTION_VLAN_POP] = {
1506 .emad_add = efx_mae_action_set_add_vlan_pop
1508 [EFX_MAE_ACTION_VLAN_PUSH] = {
1509 .emad_add = efx_mae_action_set_add_vlan_push
1511 [EFX_MAE_ACTION_ENCAP] = {
1512 .emad_add = efx_mae_action_set_add_encap
1514 [EFX_MAE_ACTION_COUNT] = {
1515 .emad_add = efx_mae_action_set_add_count
1517 [EFX_MAE_ACTION_FLAG] = {
1518 .emad_add = efx_mae_action_set_add_flag
1520 [EFX_MAE_ACTION_MARK] = {
1521 .emad_add = efx_mae_action_set_add_mark
1523 [EFX_MAE_ACTION_DELIVER] = {
1524 .emad_add = efx_mae_action_set_add_deliver
1528 static const uint32_t efx_mae_action_ordered_map =
1529 (1U << EFX_MAE_ACTION_DECAP) |
1530 (1U << EFX_MAE_ACTION_VLAN_POP) |
1531 (1U << EFX_MAE_ACTION_VLAN_PUSH) |
1533 * HW will conduct action COUNT after
1534 * the matching packet has been modified by
1535 * length-affecting actions except for ENCAP.
1537 (1U << EFX_MAE_ACTION_COUNT) |
1538 (1U << EFX_MAE_ACTION_ENCAP) |
1539 (1U << EFX_MAE_ACTION_FLAG) |
1540 (1U << EFX_MAE_ACTION_MARK) |
1541 (1U << EFX_MAE_ACTION_DELIVER);
1544 * These actions must not be added after DELIVER, but
1545 * they can have any place among the rest of
1546 * strictly ordered actions.
1548 static const uint32_t efx_mae_action_nonstrict_map =
1549 (1U << EFX_MAE_ACTION_FLAG) |
1550 (1U << EFX_MAE_ACTION_MARK);
1552 static const uint32_t efx_mae_action_repeat_map =
1553 (1U << EFX_MAE_ACTION_VLAN_POP) |
1554 (1U << EFX_MAE_ACTION_VLAN_PUSH) |
1555 (1U << EFX_MAE_ACTION_COUNT);
1558 * Add an action to an action set.
1560 * This has to be invoked in the desired action order.
1561 * An out-of-order action request will be turned down.
1563 static __checkReturn efx_rc_t
1564 efx_mae_action_set_spec_populate(
1565 __in efx_mae_actions_t *spec,
1566 __in efx_mae_action_t type,
1567 __in size_t arg_size,
1568 __in_bcount(arg_size) const uint8_t *arg)
1570 uint32_t action_mask;
1573 EFX_STATIC_ASSERT(EFX_MAE_NACTIONS <=
1574 (sizeof (efx_mae_action_ordered_map) * 8));
1575 EFX_STATIC_ASSERT(EFX_MAE_NACTIONS <=
1576 (sizeof (efx_mae_action_repeat_map) * 8));
1578 EFX_STATIC_ASSERT(EFX_MAE_ACTION_DELIVER + 1 == EFX_MAE_NACTIONS);
1579 EFX_STATIC_ASSERT(EFX_MAE_ACTION_FLAG + 1 == EFX_MAE_ACTION_MARK);
1580 EFX_STATIC_ASSERT(EFX_MAE_ACTION_MARK + 1 == EFX_MAE_ACTION_DELIVER);
1582 if (type >= EFX_ARRAY_SIZE(efx_mae_actions)) {
1587 action_mask = (1U << type);
1589 if ((spec->ema_actions & action_mask) != 0) {
1590 /* The action set already contains this action. */
1591 if ((efx_mae_action_repeat_map & action_mask) == 0) {
1592 /* Cannot add another non-repeatable action. */
1598 if ((efx_mae_action_ordered_map & action_mask) != 0) {
1599 uint32_t strict_ordered_map =
1600 efx_mae_action_ordered_map & ~efx_mae_action_nonstrict_map;
1601 uint32_t later_actions_mask =
1602 strict_ordered_map & ~(action_mask | (action_mask - 1));
1604 if ((spec->ema_actions & later_actions_mask) != 0) {
1605 /* Cannot add an action after later ordered actions. */
1611 if (efx_mae_actions[type].emad_add != NULL) {
1612 rc = efx_mae_actions[type].emad_add(spec, arg_size, arg);
1617 spec->ema_actions |= action_mask;
1628 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1632 __checkReturn efx_rc_t
1633 efx_mae_action_set_populate_decap(
1634 __in efx_mae_actions_t *spec)
1636 return (efx_mae_action_set_spec_populate(spec,
1637 EFX_MAE_ACTION_DECAP, 0, NULL));
1640 __checkReturn efx_rc_t
1641 efx_mae_action_set_populate_vlan_pop(
1642 __in efx_mae_actions_t *spec)
1644 return (efx_mae_action_set_spec_populate(spec,
1645 EFX_MAE_ACTION_VLAN_POP, 0, NULL));
1648 __checkReturn efx_rc_t
1649 efx_mae_action_set_populate_vlan_push(
1650 __in efx_mae_actions_t *spec,
1651 __in uint16_t tpid_be,
1652 __in uint16_t tci_be)
1654 efx_mae_action_vlan_push_t action;
1655 const uint8_t *arg = (const uint8_t *)&action;
1657 action.emavp_tpid_be = tpid_be;
1658 action.emavp_tci_be = tci_be;
1660 return (efx_mae_action_set_spec_populate(spec,
1661 EFX_MAE_ACTION_VLAN_PUSH, sizeof (action), arg));
1664 __checkReturn efx_rc_t
1665 efx_mae_action_set_populate_encap(
1666 __in efx_mae_actions_t *spec)
1669 * There is no argument to pass encap. header ID, thus, one does not
1670 * need to allocate an encap. header while parsing application input.
1671 * This is useful since building an action set may be done simply to
1672 * validate a rule, whilst resource allocation usually consumes time.
1674 return (efx_mae_action_set_spec_populate(spec,
1675 EFX_MAE_ACTION_ENCAP, 0, NULL));
1678 __checkReturn efx_rc_t
1679 efx_mae_action_set_populate_count(
1680 __in efx_mae_actions_t *spec)
1683 * There is no argument to pass counter ID, thus, one does not
1684 * need to allocate a counter while parsing application input.
1685 * This is useful since building an action set may be done simply to
1686 * validate a rule, whilst resource allocation usually consumes time.
1688 return (efx_mae_action_set_spec_populate(spec,
1689 EFX_MAE_ACTION_COUNT, 0, NULL));
1692 __checkReturn efx_rc_t
1693 efx_mae_action_set_populate_flag(
1694 __in efx_mae_actions_t *spec)
1696 return (efx_mae_action_set_spec_populate(spec,
1697 EFX_MAE_ACTION_FLAG, 0, NULL));
1700 __checkReturn efx_rc_t
1701 efx_mae_action_set_populate_mark(
1702 __in efx_mae_actions_t *spec,
1703 __in uint32_t mark_value)
1705 const uint8_t *arg = (const uint8_t *)&mark_value;
1707 return (efx_mae_action_set_spec_populate(spec,
1708 EFX_MAE_ACTION_MARK, sizeof (mark_value), arg));
1711 __checkReturn efx_rc_t
1712 efx_mae_action_set_populate_deliver(
1713 __in efx_mae_actions_t *spec,
1714 __in const efx_mport_sel_t *mportp)
1719 if (mportp == NULL) {
1724 arg = (const uint8_t *)&mportp->sel;
1726 return (efx_mae_action_set_spec_populate(spec,
1727 EFX_MAE_ACTION_DELIVER, sizeof (mportp->sel), arg));
1730 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1734 __checkReturn efx_rc_t
1735 efx_mae_action_set_populate_drop(
1736 __in efx_mae_actions_t *spec)
1738 efx_mport_sel_t mport;
1742 EFX_POPULATE_DWORD_1(dword,
1743 MAE_MPORT_SELECTOR_FLAT, MAE_MPORT_SELECTOR_NULL);
1746 * The constructed DWORD is little-endian,
1747 * but the resulting value is meant to be
1748 * passed to MCDIs, where it will undergo
1749 * host-order to little endian conversion.
1751 mport.sel = EFX_DWORD_FIELD(dword, EFX_DWORD_0);
1753 arg = (const uint8_t *)&mport.sel;
1755 return (efx_mae_action_set_spec_populate(spec,
1756 EFX_MAE_ACTION_DELIVER, sizeof (mport.sel), arg));
1759 __checkReturn boolean_t
1760 efx_mae_action_set_specs_equal(
1761 __in const efx_mae_actions_t *left,
1762 __in const efx_mae_actions_t *right)
1764 size_t cmp_size = EFX_FIELD_OFFSET(efx_mae_actions_t, ema_rsrc);
1767 * An action set specification consists of two parts. The first part
1768 * indicates what actions are included in the action set, as well as
1769 * extra quantitative values (in example, the number of VLAN tags to
1770 * push). The second part comprises resource IDs used by the actions.
1772 * A resource, in example, a counter, is allocated from the hardware
1773 * by the client, and it's the client who is responsible for keeping
1774 * track of allocated resources and comparing resource IDs if needed.
1776 * In this API, don't compare resource IDs in the two specifications.
1779 return ((memcmp(left, right, cmp_size) == 0) ? B_TRUE : B_FALSE);
1782 __checkReturn efx_rc_t
1783 efx_mae_match_specs_class_cmp(
1784 __in efx_nic_t *enp,
1785 __in const efx_mae_match_spec_t *left,
1786 __in const efx_mae_match_spec_t *right,
1787 __out boolean_t *have_same_classp)
1789 efx_mae_t *maep = enp->en_maep;
1790 unsigned int field_ncaps = maep->em_max_nfields;
1791 const efx_mae_field_cap_t *field_caps;
1792 const efx_mae_mv_desc_t *desc_setp;
1793 unsigned int desc_set_nentries;
1794 const efx_mae_mv_bit_desc_t *bit_desc_setp;
1795 unsigned int bit_desc_set_nentries;
1796 boolean_t have_same_class = B_TRUE;
1797 efx_mae_field_id_t field_id;
1798 const uint8_t *mvpl;
1799 const uint8_t *mvpr;
1802 switch (left->emms_type) {
1803 case EFX_MAE_RULE_OUTER:
1804 field_caps = maep->em_outer_rule_field_caps;
1805 desc_setp = __efx_mae_outer_rule_mv_desc_set;
1807 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_desc_set);
1808 bit_desc_setp = __efx_mae_outer_rule_mv_bit_desc_set;
1809 bit_desc_set_nentries =
1810 EFX_ARRAY_SIZE(__efx_mae_outer_rule_mv_bit_desc_set);
1811 mvpl = left->emms_mask_value_pairs.outer;
1812 mvpr = right->emms_mask_value_pairs.outer;
1814 case EFX_MAE_RULE_ACTION:
1815 field_caps = maep->em_action_rule_field_caps;
1816 desc_setp = __efx_mae_action_rule_mv_desc_set;
1818 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_desc_set);
1819 bit_desc_setp = __efx_mae_action_rule_mv_bit_desc_set;
1820 bit_desc_set_nentries =
1821 EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_bit_desc_set);
1822 mvpl = left->emms_mask_value_pairs.action;
1823 mvpr = right->emms_mask_value_pairs.action;
1830 if (field_caps == NULL) {
1835 if (left->emms_type != right->emms_type ||
1836 left->emms_prio != right->emms_prio) {
1838 * Rules of different types can never map to the same class.
1840 * The FW can support some set of match criteria for one
1841 * priority and not support the very same set for
1842 * another priority. Thus, two rules which have
1843 * different priorities can never map to
1846 *have_same_classp = B_FALSE;
1850 for (field_id = 0; (unsigned int)field_id < desc_set_nentries;
1852 const efx_mae_mv_desc_t *descp = &desc_setp[field_id];
1853 efx_mae_field_cap_id_t field_cap_id = descp->emmd_field_cap_id;
1854 const uint8_t *lmaskp = mvpl + descp->emmd_mask_offset;
1855 const uint8_t *rmaskp = mvpr + descp->emmd_mask_offset;
1856 size_t mask_size = descp->emmd_mask_size;
1857 const uint8_t *lvalp = mvpl + descp->emmd_value_offset;
1858 const uint8_t *rvalp = mvpr + descp->emmd_value_offset;
1859 size_t value_size = descp->emmd_value_size;
1862 continue; /* Skip array gap */
1864 if ((unsigned int)field_cap_id >= field_ncaps) {
1866 * The FW has not reported capability status for this
1867 * field. It's unknown whether any difference between
1868 * the two masks / values affects the class. The only
1869 * case when the class must be the same is when these
1870 * mask-value pairs match. Otherwise, report mismatch.
1872 if ((memcmp(lmaskp, rmaskp, mask_size) == 0) &&
1873 (memcmp(lvalp, rvalp, value_size) == 0))
1879 if (field_caps[field_cap_id].emfc_mask_affects_class) {
1880 if (memcmp(lmaskp, rmaskp, mask_size) != 0) {
1881 have_same_class = B_FALSE;
1886 if (field_caps[field_cap_id].emfc_match_affects_class) {
1887 if (memcmp(lvalp, rvalp, value_size) != 0) {
1888 have_same_class = B_FALSE;
1894 if (have_same_class == B_FALSE)
1897 for (field_id = 0; (unsigned int)field_id < bit_desc_set_nentries;
1899 const efx_mae_mv_bit_desc_t *bit_descp =
1900 &bit_desc_setp[field_id];
1901 efx_mae_field_cap_id_t bit_cap_id =
1902 bit_descp->emmbd_bit_cap_id;
1903 unsigned int byte_idx;
1904 unsigned int bit_idx;
1906 if (bit_descp->emmbd_entry_is_valid == B_FALSE)
1907 continue; /* Skip array gap */
1909 if ((unsigned int)bit_cap_id >= field_ncaps)
1913 bit_descp->emmbd_mask_ofst +
1914 bit_descp->emmbd_mask_lbn / 8;
1916 bit_descp->emmbd_mask_lbn % 8;
1918 if (field_caps[bit_cap_id].emfc_mask_affects_class &&
1919 (mvpl[byte_idx] & (1U << bit_idx)) !=
1920 (mvpr[byte_idx] & (1U << bit_idx))) {
1921 have_same_class = B_FALSE;
1926 bit_descp->emmbd_value_ofst +
1927 bit_descp->emmbd_value_lbn / 8;
1929 bit_descp->emmbd_value_lbn % 8;
1931 if (field_caps[bit_cap_id].emfc_match_affects_class &&
1932 (mvpl[byte_idx] & (1U << bit_idx)) !=
1933 (mvpr[byte_idx] & (1U << bit_idx))) {
1934 have_same_class = B_FALSE;
1940 *have_same_classp = have_same_class;
1947 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1951 __checkReturn efx_rc_t
1952 efx_mae_outer_rule_insert(
1953 __in efx_nic_t *enp,
1954 __in const efx_mae_match_spec_t *spec,
1955 __in efx_tunnel_protocol_t encap_type,
1956 __out efx_mae_rule_id_t *or_idp)
1958 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
1960 EFX_MCDI_DECLARE_BUF(payload,
1961 MC_CMD_MAE_OUTER_RULE_INSERT_IN_LENMAX_MCDI2,
1962 MC_CMD_MAE_OUTER_RULE_INSERT_OUT_LEN);
1963 uint32_t encap_type_mcdi;
1964 efx_mae_rule_id_t or_id;
1968 EFX_STATIC_ASSERT(sizeof (or_idp->id) ==
1969 MC_CMD_MAE_OUTER_RULE_INSERT_OUT_OR_ID_LEN);
1971 EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID ==
1972 MC_CMD_MAE_OUTER_RULE_INSERT_OUT_OUTER_RULE_ID_NULL);
1974 if (encp->enc_mae_supported == B_FALSE) {
1979 if (spec->emms_type != EFX_MAE_RULE_OUTER) {
1984 switch (encap_type) {
1985 case EFX_TUNNEL_PROTOCOL_NONE:
1986 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NONE;
1988 case EFX_TUNNEL_PROTOCOL_VXLAN:
1989 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_VXLAN;
1991 case EFX_TUNNEL_PROTOCOL_GENEVE:
1992 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_GENEVE;
1994 case EFX_TUNNEL_PROTOCOL_NVGRE:
1995 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NVGRE;
2002 req.emr_cmd = MC_CMD_MAE_OUTER_RULE_INSERT;
2003 req.emr_in_buf = payload;
2004 req.emr_in_length = MC_CMD_MAE_OUTER_RULE_INSERT_IN_LENMAX_MCDI2;
2005 req.emr_out_buf = payload;
2006 req.emr_out_length = MC_CMD_MAE_OUTER_RULE_INSERT_OUT_LEN;
2008 MCDI_IN_SET_DWORD(req,
2009 MAE_OUTER_RULE_INSERT_IN_ENCAP_TYPE, encap_type_mcdi);
2011 MCDI_IN_SET_DWORD(req, MAE_OUTER_RULE_INSERT_IN_PRIO, spec->emms_prio);
2014 * Mask-value pairs have been stored in the byte order needed for the
2015 * MCDI request and are thus safe to be copied directly to the buffer.
2016 * The library cares about byte order in efx_mae_match_spec_field_set().
2018 EFX_STATIC_ASSERT(sizeof (spec->emms_mask_value_pairs.outer) >=
2019 MAE_ENC_FIELD_PAIRS_LEN);
2020 offset = MC_CMD_MAE_OUTER_RULE_INSERT_IN_FIELD_MATCH_CRITERIA_OFST;
2021 memcpy(payload + offset, spec->emms_mask_value_pairs.outer,
2022 MAE_ENC_FIELD_PAIRS_LEN);
2024 efx_mcdi_execute(enp, &req);
2026 if (req.emr_rc != 0) {
2031 if (req.emr_out_length_used < MC_CMD_MAE_OUTER_RULE_INSERT_OUT_LEN) {
2036 or_id.id = MCDI_OUT_DWORD(req, MAE_OUTER_RULE_INSERT_OUT_OR_ID);
2037 if (or_id.id == EFX_MAE_RSRC_ID_INVALID) {
2042 or_idp->id = or_id.id;
2057 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2061 __checkReturn efx_rc_t
2062 efx_mae_outer_rule_remove(
2063 __in efx_nic_t *enp,
2064 __in const efx_mae_rule_id_t *or_idp)
2066 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2068 EFX_MCDI_DECLARE_BUF(payload,
2069 MC_CMD_MAE_OUTER_RULE_REMOVE_IN_LEN(1),
2070 MC_CMD_MAE_OUTER_RULE_REMOVE_OUT_LEN(1));
2073 if (encp->enc_mae_supported == B_FALSE) {
2078 req.emr_cmd = MC_CMD_MAE_OUTER_RULE_REMOVE;
2079 req.emr_in_buf = payload;
2080 req.emr_in_length = MC_CMD_MAE_OUTER_RULE_REMOVE_IN_LEN(1);
2081 req.emr_out_buf = payload;
2082 req.emr_out_length = MC_CMD_MAE_OUTER_RULE_REMOVE_OUT_LEN(1);
2084 MCDI_IN_SET_DWORD(req, MAE_OUTER_RULE_REMOVE_IN_OR_ID, or_idp->id);
2086 efx_mcdi_execute(enp, &req);
2088 if (req.emr_rc != 0) {
2093 if (req.emr_out_length_used < MC_CMD_MAE_OUTER_RULE_REMOVE_OUT_LENMIN) {
2098 if (MCDI_OUT_DWORD(req, MAE_OUTER_RULE_REMOVE_OUT_REMOVED_OR_ID) !=
2100 /* Firmware failed to remove the outer rule. */
2114 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2118 __checkReturn efx_rc_t
2119 efx_mae_match_spec_outer_rule_id_set(
2120 __in efx_mae_match_spec_t *spec,
2121 __in const efx_mae_rule_id_t *or_idp)
2123 uint32_t full_mask = UINT32_MAX;
2126 if (spec->emms_type != EFX_MAE_RULE_ACTION) {
2131 if (or_idp == NULL) {
2136 rc = efx_mae_match_spec_field_set(spec, EFX_MAE_FIELD_OUTER_RULE_ID,
2137 sizeof (or_idp->id), (const uint8_t *)&or_idp->id,
2138 sizeof (full_mask), (const uint8_t *)&full_mask);
2149 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2153 __checkReturn efx_rc_t
2154 efx_mae_encap_header_alloc(
2155 __in efx_nic_t *enp,
2156 __in efx_tunnel_protocol_t encap_type,
2157 __in_bcount(header_size) uint8_t *header_data,
2158 __in size_t header_size,
2159 __out efx_mae_eh_id_t *eh_idp)
2161 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2163 EFX_MCDI_DECLARE_BUF(payload,
2164 MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_LENMAX_MCDI2,
2165 MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN);
2166 uint32_t encap_type_mcdi;
2167 efx_mae_eh_id_t eh_id;
2170 EFX_STATIC_ASSERT(sizeof (eh_idp->id) ==
2171 MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_LEN);
2173 EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID ==
2174 MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_NULL);
2176 if (encp->enc_mae_supported == B_FALSE) {
2181 switch (encap_type) {
2182 case EFX_TUNNEL_PROTOCOL_NONE:
2183 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NONE;
2185 case EFX_TUNNEL_PROTOCOL_VXLAN:
2186 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_VXLAN;
2188 case EFX_TUNNEL_PROTOCOL_GENEVE:
2189 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_GENEVE;
2191 case EFX_TUNNEL_PROTOCOL_NVGRE:
2192 encap_type_mcdi = MAE_MCDI_ENCAP_TYPE_NVGRE;
2200 MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2) {
2205 req.emr_cmd = MC_CMD_MAE_ENCAP_HEADER_ALLOC;
2206 req.emr_in_buf = payload;
2207 req.emr_in_length = MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_LEN(header_size);
2208 req.emr_out_buf = payload;
2209 req.emr_out_length = MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN;
2211 MCDI_IN_SET_DWORD(req,
2212 MAE_ENCAP_HEADER_ALLOC_IN_ENCAP_TYPE, encap_type_mcdi);
2214 memcpy(payload + MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_OFST,
2215 header_data, header_size);
2217 efx_mcdi_execute(enp, &req);
2219 if (req.emr_rc != 0) {
2224 if (req.emr_out_length_used < MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_LEN) {
2229 eh_id.id = MCDI_OUT_DWORD(req,
2230 MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID);
2232 if (eh_id.id == EFX_MAE_RSRC_ID_INVALID) {
2237 eh_idp->id = eh_id.id;
2252 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2256 __checkReturn efx_rc_t
2257 efx_mae_encap_header_free(
2258 __in efx_nic_t *enp,
2259 __in const efx_mae_eh_id_t *eh_idp)
2261 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2263 EFX_MCDI_DECLARE_BUF(payload,
2264 MC_CMD_MAE_ENCAP_HEADER_FREE_IN_LEN(1),
2265 MC_CMD_MAE_ENCAP_HEADER_FREE_OUT_LEN(1));
2268 if (encp->enc_mae_supported == B_FALSE) {
2273 req.emr_cmd = MC_CMD_MAE_ENCAP_HEADER_FREE;
2274 req.emr_in_buf = payload;
2275 req.emr_in_length = MC_CMD_MAE_ENCAP_HEADER_FREE_IN_LEN(1);
2276 req.emr_out_buf = payload;
2277 req.emr_out_length = MC_CMD_MAE_ENCAP_HEADER_FREE_OUT_LEN(1);
2279 MCDI_IN_SET_DWORD(req, MAE_ENCAP_HEADER_FREE_IN_EH_ID, eh_idp->id);
2281 efx_mcdi_execute(enp, &req);
2283 if (req.emr_rc != 0) {
2288 if (MCDI_OUT_DWORD(req, MAE_ENCAP_HEADER_FREE_OUT_FREED_EH_ID) !=
2290 /* Firmware failed to remove the encap. header. */
2302 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2306 __checkReturn efx_rc_t
2307 efx_mae_action_set_fill_in_eh_id(
2308 __in efx_mae_actions_t *spec,
2309 __in const efx_mae_eh_id_t *eh_idp)
2313 if ((spec->ema_actions & (1U << EFX_MAE_ACTION_ENCAP)) == 0) {
2315 * The caller has not intended to have action ENCAP originally,
2316 * hence, this attempt to indicate encap. header ID is invalid.
2322 if (spec->ema_rsrc.emar_eh_id.id != EFX_MAE_RSRC_ID_INVALID) {
2323 /* The caller attempts to indicate encap. header ID twice. */
2328 if (eh_idp->id == EFX_MAE_RSRC_ID_INVALID) {
2333 spec->ema_rsrc.emar_eh_id.id = eh_idp->id;
2342 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2346 __checkReturn efx_rc_t
2347 efx_mae_action_set_alloc(
2348 __in efx_nic_t *enp,
2349 __in const efx_mae_actions_t *spec,
2350 __out efx_mae_aset_id_t *aset_idp)
2352 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2354 EFX_MCDI_DECLARE_BUF(payload,
2355 MC_CMD_MAE_ACTION_SET_ALLOC_IN_LEN,
2356 MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN);
2357 efx_mae_aset_id_t aset_id;
2360 if (encp->enc_mae_supported == B_FALSE) {
2365 req.emr_cmd = MC_CMD_MAE_ACTION_SET_ALLOC;
2366 req.emr_in_buf = payload;
2367 req.emr_in_length = MC_CMD_MAE_ACTION_SET_ALLOC_IN_LEN;
2368 req.emr_out_buf = payload;
2369 req.emr_out_length = MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN;
2372 * TODO: Remove these EFX_MAE_RSRC_ID_INVALID assignments once the
2373 * corresponding resource types are supported by the implementation.
2374 * Use proper resource ID assignments instead.
2376 MCDI_IN_SET_DWORD(req,
2377 MAE_ACTION_SET_ALLOC_IN_COUNTER_LIST_ID, EFX_MAE_RSRC_ID_INVALID);
2379 if ((spec->ema_actions & (1U << EFX_MAE_ACTION_DECAP)) != 0) {
2380 MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
2381 MAE_ACTION_SET_ALLOC_IN_DECAP, 1);
2384 MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
2385 MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop);
2387 if (spec->ema_n_vlan_tags_to_push > 0) {
2388 unsigned int outer_tag_idx;
2390 MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
2391 MAE_ACTION_SET_ALLOC_IN_VLAN_PUSH,
2392 spec->ema_n_vlan_tags_to_push);
2394 if (spec->ema_n_vlan_tags_to_push ==
2395 EFX_MAE_VLAN_PUSH_MAX_NTAGS) {
2396 MCDI_IN_SET_WORD(req,
2397 MAE_ACTION_SET_ALLOC_IN_VLAN1_PROTO_BE,
2398 spec->ema_vlan_push_descs[0].emavp_tpid_be);
2399 MCDI_IN_SET_WORD(req,
2400 MAE_ACTION_SET_ALLOC_IN_VLAN1_TCI_BE,
2401 spec->ema_vlan_push_descs[0].emavp_tci_be);
2404 outer_tag_idx = spec->ema_n_vlan_tags_to_push - 1;
2406 MCDI_IN_SET_WORD(req, MAE_ACTION_SET_ALLOC_IN_VLAN0_PROTO_BE,
2407 spec->ema_vlan_push_descs[outer_tag_idx].emavp_tpid_be);
2408 MCDI_IN_SET_WORD(req, MAE_ACTION_SET_ALLOC_IN_VLAN0_TCI_BE,
2409 spec->ema_vlan_push_descs[outer_tag_idx].emavp_tci_be);
2412 MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID,
2413 spec->ema_rsrc.emar_eh_id.id);
2414 MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_COUNTER_ID,
2415 spec->ema_rsrc.emar_counter_id.id);
2417 if ((spec->ema_actions & (1U << EFX_MAE_ACTION_FLAG)) != 0) {
2418 MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
2419 MAE_ACTION_SET_ALLOC_IN_FLAG, 1);
2422 if ((spec->ema_actions & (1U << EFX_MAE_ACTION_MARK)) != 0) {
2423 MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
2424 MAE_ACTION_SET_ALLOC_IN_MARK, 1);
2426 MCDI_IN_SET_DWORD(req,
2427 MAE_ACTION_SET_ALLOC_IN_MARK_VALUE, spec->ema_mark_value);
2430 MCDI_IN_SET_DWORD(req,
2431 MAE_ACTION_SET_ALLOC_IN_DELIVER, spec->ema_deliver_mport.sel);
2433 MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_SRC_MAC_ID,
2434 MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL);
2435 MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_DST_MAC_ID,
2436 MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL);
2438 efx_mcdi_execute(enp, &req);
2440 if (req.emr_rc != 0) {
2445 if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN) {
2450 aset_id.id = MCDI_OUT_DWORD(req, MAE_ACTION_SET_ALLOC_OUT_AS_ID);
2451 if (aset_id.id == EFX_MAE_RSRC_ID_INVALID) {
2456 aset_idp->id = aset_id.id;
2467 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2471 __checkReturn unsigned int
2472 efx_mae_action_set_get_nb_count(
2473 __in const efx_mae_actions_t *spec)
2475 return (spec->ema_n_count_actions);
2478 __checkReturn efx_rc_t
2479 efx_mae_action_set_fill_in_counter_id(
2480 __in efx_mae_actions_t *spec,
2481 __in const efx_counter_t *counter_idp)
2485 if ((spec->ema_actions & (1U << EFX_MAE_ACTION_COUNT)) == 0) {
2487 * Invalid to add counter ID if spec does not have COUNT action.
2493 if (spec->ema_n_count_actions != 1) {
2495 * Having multiple COUNT actions in the spec requires a counter
2496 * list to be used. This API must only be used for a single
2497 * counter per spec. Turn down the request as inappropriate.
2503 if (spec->ema_rsrc.emar_counter_id.id != EFX_MAE_RSRC_ID_INVALID) {
2504 /* The caller attempts to indicate counter ID twice. */
2509 if (counter_idp->id == EFX_MAE_RSRC_ID_INVALID) {
2514 spec->ema_rsrc.emar_counter_id.id = counter_idp->id;
2525 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2529 __checkReturn efx_rc_t
2530 efx_mae_counters_alloc(
2531 __in efx_nic_t *enp,
2532 __in uint32_t n_counters,
2533 __out uint32_t *n_allocatedp,
2534 __out_ecount(n_counters) efx_counter_t *countersp,
2535 __out_opt uint32_t *gen_countp)
2537 EFX_MCDI_DECLARE_BUF(payload,
2538 MC_CMD_MAE_COUNTER_ALLOC_IN_LEN,
2539 MC_CMD_MAE_COUNTER_ALLOC_OUT_LENMAX_MCDI2);
2540 efx_mae_t *maep = enp->en_maep;
2541 uint32_t n_allocated;
2546 if (n_counters > maep->em_max_ncounters ||
2547 n_counters < MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MINNUM ||
2548 n_counters > MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MAXNUM_MCDI2) {
2553 req.emr_cmd = MC_CMD_MAE_COUNTER_ALLOC;
2554 req.emr_in_buf = payload;
2555 req.emr_in_length = MC_CMD_MAE_COUNTER_ALLOC_IN_LEN;
2556 req.emr_out_buf = payload;
2557 req.emr_out_length = MC_CMD_MAE_COUNTER_ALLOC_OUT_LEN(n_counters);
2559 MCDI_IN_SET_DWORD(req, MAE_COUNTER_ALLOC_IN_REQUESTED_COUNT,
2562 efx_mcdi_execute(enp, &req);
2564 if (req.emr_rc != 0) {
2569 if (req.emr_out_length_used < MC_CMD_MAE_COUNTER_ALLOC_OUT_LENMIN) {
2574 n_allocated = MCDI_OUT_DWORD(req,
2575 MAE_COUNTER_ALLOC_OUT_COUNTER_ID_COUNT);
2576 if (n_allocated < MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_MINNUM) {
2581 for (i = 0; i < n_allocated; i++) {
2582 countersp[i].id = MCDI_OUT_INDEXED_DWORD(req,
2583 MAE_COUNTER_ALLOC_OUT_COUNTER_ID, i);
2586 if (gen_countp != NULL) {
2587 *gen_countp = MCDI_OUT_DWORD(req,
2588 MAE_COUNTER_ALLOC_OUT_GENERATION_COUNT);
2591 *n_allocatedp = n_allocated;
2602 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2607 __checkReturn efx_rc_t
2608 efx_mae_counters_free(
2609 __in efx_nic_t *enp,
2610 __in uint32_t n_counters,
2611 __out uint32_t *n_freedp,
2612 __in_ecount(n_counters) const efx_counter_t *countersp,
2613 __out_opt uint32_t *gen_countp)
2615 EFX_MCDI_DECLARE_BUF(payload,
2616 MC_CMD_MAE_COUNTER_FREE_IN_LENMAX_MCDI2,
2617 MC_CMD_MAE_COUNTER_FREE_OUT_LENMAX_MCDI2);
2618 efx_mae_t *maep = enp->en_maep;
2624 if (n_counters > maep->em_max_ncounters ||
2625 n_counters < MC_CMD_MAE_COUNTER_FREE_IN_FREE_COUNTER_ID_MINNUM ||
2627 MC_CMD_MAE_COUNTER_FREE_IN_FREE_COUNTER_ID_MAXNUM_MCDI2) {
2632 req.emr_cmd = MC_CMD_MAE_COUNTER_FREE;
2633 req.emr_in_buf = payload;
2634 req.emr_in_length = MC_CMD_MAE_COUNTER_FREE_IN_LEN(n_counters);
2635 req.emr_out_buf = payload;
2636 req.emr_out_length = MC_CMD_MAE_COUNTER_FREE_OUT_LEN(n_counters);
2638 for (i = 0; i < n_counters; i++) {
2639 MCDI_IN_SET_INDEXED_DWORD(req,
2640 MAE_COUNTER_FREE_IN_FREE_COUNTER_ID, i, countersp[i].id);
2642 MCDI_IN_SET_DWORD(req, MAE_COUNTER_FREE_IN_COUNTER_ID_COUNT,
2645 efx_mcdi_execute(enp, &req);
2647 if (req.emr_rc != 0) {
2652 if (req.emr_out_length_used < MC_CMD_MAE_COUNTER_FREE_OUT_LENMIN) {
2657 n_freed = MCDI_OUT_DWORD(req, MAE_COUNTER_FREE_OUT_COUNTER_ID_COUNT);
2659 if (n_freed < MC_CMD_MAE_COUNTER_FREE_OUT_FREED_COUNTER_ID_MINNUM) {
2664 if (gen_countp != NULL) {
2665 *gen_countp = MCDI_OUT_DWORD(req,
2666 MAE_COUNTER_FREE_OUT_GENERATION_COUNT);
2669 *n_freedp = n_freed;
2680 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2685 __checkReturn efx_rc_t
2686 efx_mae_counters_stream_start(
2687 __in efx_nic_t *enp,
2688 __in uint16_t rxq_id,
2689 __in uint16_t packet_size,
2690 __in uint32_t flags_in,
2691 __out uint32_t *flags_out)
2694 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_MAE_COUNTERS_STREAM_START_IN_LEN,
2695 MC_CMD_MAE_COUNTERS_STREAM_START_OUT_LEN);
2698 EFX_STATIC_ASSERT(EFX_MAE_COUNTERS_STREAM_IN_ZERO_SQUASH_DISABLE ==
2699 1U << MC_CMD_MAE_COUNTERS_STREAM_START_IN_ZERO_SQUASH_DISABLE_LBN);
2701 EFX_STATIC_ASSERT(EFX_MAE_COUNTERS_STREAM_OUT_USES_CREDITS ==
2702 1U << MC_CMD_MAE_COUNTERS_STREAM_START_OUT_USES_CREDITS_LBN);
2704 req.emr_cmd = MC_CMD_MAE_COUNTERS_STREAM_START;
2705 req.emr_in_buf = payload;
2706 req.emr_in_length = MC_CMD_MAE_COUNTERS_STREAM_START_IN_LEN;
2707 req.emr_out_buf = payload;
2708 req.emr_out_length = MC_CMD_MAE_COUNTERS_STREAM_START_OUT_LEN;
2710 MCDI_IN_SET_WORD(req, MAE_COUNTERS_STREAM_START_IN_QID, rxq_id);
2711 MCDI_IN_SET_WORD(req, MAE_COUNTERS_STREAM_START_IN_PACKET_SIZE,
2713 MCDI_IN_SET_DWORD(req, MAE_COUNTERS_STREAM_START_IN_FLAGS, flags_in);
2715 efx_mcdi_execute(enp, &req);
2717 if (req.emr_rc != 0) {
2722 if (req.emr_out_length_used <
2723 MC_CMD_MAE_COUNTERS_STREAM_START_OUT_LEN) {
2728 *flags_out = MCDI_OUT_DWORD(req, MAE_COUNTERS_STREAM_START_OUT_FLAGS);
2735 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2740 __checkReturn efx_rc_t
2741 efx_mae_counters_stream_stop(
2742 __in efx_nic_t *enp,
2743 __in uint16_t rxq_id,
2744 __out_opt uint32_t *gen_countp)
2747 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_MAE_COUNTERS_STREAM_STOP_IN_LEN,
2748 MC_CMD_MAE_COUNTERS_STREAM_STOP_OUT_LEN);
2751 req.emr_cmd = MC_CMD_MAE_COUNTERS_STREAM_STOP;
2752 req.emr_in_buf = payload;
2753 req.emr_in_length = MC_CMD_MAE_COUNTERS_STREAM_STOP_IN_LEN;
2754 req.emr_out_buf = payload;
2755 req.emr_out_length = MC_CMD_MAE_COUNTERS_STREAM_STOP_OUT_LEN;
2757 MCDI_IN_SET_WORD(req, MAE_COUNTERS_STREAM_STOP_IN_QID, rxq_id);
2759 efx_mcdi_execute(enp, &req);
2761 if (req.emr_rc != 0) {
2766 if (req.emr_out_length_used <
2767 MC_CMD_MAE_COUNTERS_STREAM_STOP_OUT_LEN) {
2772 if (gen_countp != NULL) {
2773 *gen_countp = MCDI_OUT_DWORD(req,
2774 MAE_COUNTERS_STREAM_STOP_OUT_GENERATION_COUNT);
2782 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2787 __checkReturn efx_rc_t
2788 efx_mae_counters_stream_give_credits(
2789 __in efx_nic_t *enp,
2790 __in uint32_t n_credits)
2793 EFX_MCDI_DECLARE_BUF(payload,
2794 MC_CMD_MAE_COUNTERS_STREAM_GIVE_CREDITS_IN_LEN,
2795 MC_CMD_MAE_COUNTERS_STREAM_GIVE_CREDITS_OUT_LEN);
2798 req.emr_cmd = MC_CMD_MAE_COUNTERS_STREAM_GIVE_CREDITS;
2799 req.emr_in_buf = payload;
2800 req.emr_in_length = MC_CMD_MAE_COUNTERS_STREAM_GIVE_CREDITS_IN_LEN;
2801 req.emr_out_buf = payload;
2802 req.emr_out_length = MC_CMD_MAE_COUNTERS_STREAM_GIVE_CREDITS_OUT_LEN;
2804 MCDI_IN_SET_DWORD(req, MAE_COUNTERS_STREAM_GIVE_CREDITS_IN_NUM_CREDITS,
2807 efx_mcdi_execute(enp, &req);
2809 if (req.emr_rc != 0) {
2817 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2822 __checkReturn efx_rc_t
2823 efx_mae_action_set_free(
2824 __in efx_nic_t *enp,
2825 __in const efx_mae_aset_id_t *aset_idp)
2827 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2829 EFX_MCDI_DECLARE_BUF(payload,
2830 MC_CMD_MAE_ACTION_SET_FREE_IN_LEN(1),
2831 MC_CMD_MAE_ACTION_SET_FREE_OUT_LEN(1));
2834 if (encp->enc_mae_supported == B_FALSE) {
2839 req.emr_cmd = MC_CMD_MAE_ACTION_SET_FREE;
2840 req.emr_in_buf = payload;
2841 req.emr_in_length = MC_CMD_MAE_ACTION_SET_FREE_IN_LEN(1);
2842 req.emr_out_buf = payload;
2843 req.emr_out_length = MC_CMD_MAE_ACTION_SET_FREE_OUT_LEN(1);
2845 MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_FREE_IN_AS_ID, aset_idp->id);
2847 efx_mcdi_execute(enp, &req);
2849 if (req.emr_rc != 0) {
2854 if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_FREE_OUT_LENMIN) {
2859 if (MCDI_OUT_DWORD(req, MAE_ACTION_SET_FREE_OUT_FREED_AS_ID) !=
2861 /* Firmware failed to free the action set. */
2875 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2879 __checkReturn efx_rc_t
2880 efx_mae_action_rule_insert(
2881 __in efx_nic_t *enp,
2882 __in const efx_mae_match_spec_t *spec,
2883 __in const efx_mae_aset_list_id_t *asl_idp,
2884 __in const efx_mae_aset_id_t *as_idp,
2885 __out efx_mae_rule_id_t *ar_idp)
2887 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2889 EFX_MCDI_DECLARE_BUF(payload,
2890 MC_CMD_MAE_ACTION_RULE_INSERT_IN_LENMAX_MCDI2,
2891 MC_CMD_MAE_ACTION_RULE_INSERT_OUT_LEN);
2892 efx_oword_t *rule_response;
2893 efx_mae_rule_id_t ar_id;
2897 EFX_STATIC_ASSERT(sizeof (ar_idp->id) ==
2898 MC_CMD_MAE_ACTION_RULE_INSERT_OUT_AR_ID_LEN);
2900 EFX_STATIC_ASSERT(EFX_MAE_RSRC_ID_INVALID ==
2901 MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL);
2903 if (encp->enc_mae_supported == B_FALSE) {
2908 if (spec->emms_type != EFX_MAE_RULE_ACTION ||
2909 (asl_idp != NULL && as_idp != NULL) ||
2910 (asl_idp == NULL && as_idp == NULL)) {
2915 req.emr_cmd = MC_CMD_MAE_ACTION_RULE_INSERT;
2916 req.emr_in_buf = payload;
2917 req.emr_in_length = MC_CMD_MAE_ACTION_RULE_INSERT_IN_LENMAX_MCDI2;
2918 req.emr_out_buf = payload;
2919 req.emr_out_length = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_LEN;
2921 EFX_STATIC_ASSERT(sizeof (*rule_response) <=
2922 MC_CMD_MAE_ACTION_RULE_INSERT_IN_RESPONSE_LEN);
2923 offset = MC_CMD_MAE_ACTION_RULE_INSERT_IN_RESPONSE_OFST;
2924 rule_response = (efx_oword_t *)(payload + offset);
2925 EFX_POPULATE_OWORD_3(*rule_response,
2926 MAE_ACTION_RULE_RESPONSE_ASL_ID,
2927 (asl_idp != NULL) ? asl_idp->id : EFX_MAE_RSRC_ID_INVALID,
2928 MAE_ACTION_RULE_RESPONSE_AS_ID,
2929 (as_idp != NULL) ? as_idp->id : EFX_MAE_RSRC_ID_INVALID,
2930 MAE_ACTION_RULE_RESPONSE_COUNTER_ID, EFX_MAE_RSRC_ID_INVALID);
2932 MCDI_IN_SET_DWORD(req, MAE_ACTION_RULE_INSERT_IN_PRIO, spec->emms_prio);
2935 * Mask-value pairs have been stored in the byte order needed for the
2936 * MCDI request and are thus safe to be copied directly to the buffer.
2938 EFX_STATIC_ASSERT(sizeof (spec->emms_mask_value_pairs.action) >=
2939 MAE_FIELD_MASK_VALUE_PAIRS_V2_LEN);
2940 offset = MC_CMD_MAE_ACTION_RULE_INSERT_IN_MATCH_CRITERIA_OFST;
2941 memcpy(payload + offset, spec->emms_mask_value_pairs.action,
2942 MAE_FIELD_MASK_VALUE_PAIRS_V2_LEN);
2944 efx_mcdi_execute(enp, &req);
2946 if (req.emr_rc != 0) {
2951 if (req.emr_out_length_used < MC_CMD_MAE_ACTION_RULE_INSERT_OUT_LEN) {
2956 ar_id.id = MCDI_OUT_DWORD(req, MAE_ACTION_RULE_INSERT_OUT_AR_ID);
2957 if (ar_id.id == EFX_MAE_RSRC_ID_INVALID) {
2962 ar_idp->id = ar_id.id;
2975 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2979 __checkReturn efx_rc_t
2980 efx_mae_action_rule_remove(
2981 __in efx_nic_t *enp,
2982 __in const efx_mae_rule_id_t *ar_idp)
2984 const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
2986 EFX_MCDI_DECLARE_BUF(payload,
2987 MC_CMD_MAE_ACTION_RULE_DELETE_IN_LEN(1),
2988 MC_CMD_MAE_ACTION_RULE_DELETE_OUT_LEN(1));
2991 if (encp->enc_mae_supported == B_FALSE) {
2996 req.emr_cmd = MC_CMD_MAE_ACTION_RULE_DELETE;
2997 req.emr_in_buf = payload;
2998 req.emr_in_length = MC_CMD_MAE_ACTION_RULE_DELETE_IN_LEN(1);
2999 req.emr_out_buf = payload;
3000 req.emr_out_length = MC_CMD_MAE_ACTION_RULE_DELETE_OUT_LEN(1);
3002 MCDI_IN_SET_DWORD(req, MAE_ACTION_RULE_DELETE_IN_AR_ID, ar_idp->id);
3004 efx_mcdi_execute(enp, &req);
3006 if (req.emr_rc != 0) {
3011 if (req.emr_out_length_used <
3012 MC_CMD_MAE_ACTION_RULE_DELETE_OUT_LENMIN) {
3017 if (MCDI_OUT_DWORD(req, MAE_ACTION_RULE_DELETE_OUT_DELETED_AR_ID) !=
3019 /* Firmware failed to delete the action rule. */
3033 EFSYS_PROBE1(fail1, efx_rc_t, rc);
3037 #endif /* EFSYS_OPT_MAE */