Lines Matching +full:row +full:- +full:stride

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright 2020-2022 Xilinx Inc.
29 return -EINVAL; in efx_mae_allocate_mport()
31 return -EINVAL; in efx_mae_allocate_mport()
42 return -EIO; in efx_mae_allocate_mport()
64 MAE_MPORT_SELECTOR_PPORT_ID, efx->port_num); in efx_mae_mport_wire()
104 return -EIO; in efx_mae_fw_lookup_mport()
120 efx->net_dev->mtu); in efx_mae_start_counters()
129 return -EIO; in efx_mae_start_counters()
132 netif_dbg(efx, drv, efx->net_dev, in efx_mae_start_counters()
134 rx_queue->grant_credits = true; in efx_mae_start_counters()
138 netif_err(efx, drv, efx->net_dev, in efx_mae_start_counters()
146 return -EOPNOTSUPP; in efx_mae_start_counters()
154 if ((s32)(flush_gen[i] - seen_gen[i]) > 0) in efx_mae_counters_flushed()
174 netif_dbg(efx, drv, efx->net_dev, "Draining counters:\n"); in efx_mae_stop_counters()
177 efx->tc->flush_gen[i] = MCDI_ARRAY_DWORD(outbuf, in efx_mae_stop_counters()
180 netif_dbg(efx, drv, efx->net_dev, in efx_mae_stop_counters()
182 efx->tc->flush_gen[i]); in efx_mae_stop_counters()
185 efx->tc->flush_counters = true; in efx_mae_stop_counters()
187 /* Drain can take up to 2 seconds owing to FWRIVERHD-2884; whatever in efx_mae_stop_counters()
191 if (!wait_event_timeout(efx->tc->flush_wq, in efx_mae_stop_counters()
192 efx_mae_counters_flushed(efx->tc->flush_gen, in efx_mae_stop_counters()
193 efx->tc->seen_gen), in efx_mae_stop_counters()
195 netif_warn(efx, drv, efx->net_dev, in efx_mae_stop_counters()
198 efx->tc->flush_counters = false; in efx_mae_stop_counters()
208 struct efx_nic *efx = rx_queue->efx; in efx_mae_counters_grant_credits()
212 credits = READ_ONCE(rx_queue->notified_count) - rx_queue->granted_count; in efx_mae_counters_grant_credits()
217 rx_queue->granted_count += credits; in efx_mae_counters_grant_credits()
240 rc = -EIO; in efx_mae_table_get_desc()
244 desc->type = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_TYPE); in efx_mae_table_get_desc()
245 desc->key_width = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_KEY_WIDTH); in efx_mae_table_get_desc()
246 desc->resp_width = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_RESP_WIDTH); in efx_mae_table_get_desc()
247 desc->n_keys = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_N_KEY_FIELDS); in efx_mae_table_get_desc()
248 desc->n_resps = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_N_RESP_FIELDS); in efx_mae_table_get_desc()
249 desc->n_prios = MCDI_WORD(outbuf, TABLE_DESCRIPTOR_OUT_N_PRIORITIES); in efx_mae_table_get_desc()
250 desc->flags = MCDI_BYTE(outbuf, TABLE_DESCRIPTOR_OUT_FLAGS); in efx_mae_table_get_desc()
251 rc = -EOPNOTSUPP; in efx_mae_table_get_desc()
252 if (desc->flags) in efx_mae_table_get_desc()
254 desc->scheme = MCDI_BYTE(outbuf, TABLE_DESCRIPTOR_OUT_SCHEME); in efx_mae_table_get_desc()
255 if (desc->scheme) in efx_mae_table_get_desc()
257 rc = -ENOMEM; in efx_mae_table_get_desc()
258 desc->keys = kcalloc(desc->n_keys, in efx_mae_table_get_desc()
261 if (!desc->keys) in efx_mae_table_get_desc()
263 desc->resps = kcalloc(desc->n_resps, in efx_mae_table_get_desc()
266 if (!desc->resps) in efx_mae_table_get_desc()
273 for (i = 0; i + offset < desc->n_keys + desc->n_resps; i++) { in efx_mae_table_get_desc()
281 if (i + offset < desc->n_keys) in efx_mae_table_get_desc()
282 field = desc->keys + i + offset; in efx_mae_table_get_desc()
284 field = desc->resps + (i + offset - desc->n_keys); in efx_mae_table_get_desc()
287 field->field_id = MCDI_STRUCT_WORD(fdesc, in efx_mae_table_get_desc()
289 field->lbn = MCDI_STRUCT_WORD(fdesc, TABLE_FIELD_DESCR_LBN); in efx_mae_table_get_desc()
290 field->width = MCDI_STRUCT_WORD(fdesc, TABLE_FIELD_DESCR_WIDTH); in efx_mae_table_get_desc()
291 field->masking = MCDI_STRUCT_BYTE(fdesc, TABLE_FIELD_DESCR_MASK_TYPE); in efx_mae_table_get_desc()
292 field->scheme = MCDI_STRUCT_BYTE(fdesc, TABLE_FIELD_DESCR_SCHEME); in efx_mae_table_get_desc()
297 kfree(desc->keys); in efx_mae_table_get_desc()
298 kfree(desc->resps); in efx_mae_table_get_desc()
312 return -EPROTO; in efx_mae_table_hook_find()
316 efx_mae_table_hook_find((_desc)->n_keys, (_desc)->keys, _id)
318 efx_mae_table_hook_find((_desc)->n_resps, (_desc)->resps, _id)
321 int _rc = TABLE_FIND_KEY(&_meta->desc, TABLE_FIELD_ID_##_mcdi_name); \
324 _rc = -EOPNOTSUPP; \
326 _meta->keys._name##_idx = _rc; \
332 int _rc = TABLE_FIND_RESP(&_meta->desc, TABLE_FIELD_ID_##_mcdi_name); \
335 _rc = -EOPNOTSUPP; \
337 _meta->resps._name##_idx = _rc; \
384 meta_ct->hooked = true; in efx_mae_table_hook_ct()
390 kfree(desc->keys); in efx_mae_table_free_desc()
391 kfree(desc->resps); in efx_mae_table_free_desc()
405 efx->tc->meta_ct.hooked = false; in efx_mae_check_table_exists()
439 efx->tc->meta_ct.hooked = false; in efx_mae_get_tables()
441 rc = efx_mae_table_get_desc(efx, &efx->tc->meta_ct.desc, in efx_mae_get_tables()
444 pci_info(efx->pci_dev, in efx_mae_get_tables()
450 rc = efx_mae_table_hook_ct(efx, &efx->tc->meta_ct); in efx_mae_get_tables()
452 pci_info(efx->pci_dev, in efx_mae_get_tables()
458 pci_info(efx->pci_dev, in efx_mae_get_tables()
466 efx_mae_table_free_desc(&efx->tc->meta_ct.desc); in efx_mae_free_tables()
467 efx->tc->meta_ct.hooked = false; in efx_mae_free_tables()
483 return -EIO; in efx_mae_get_basic_caps()
484 caps->match_field_count = MCDI_DWORD(outbuf, MAE_GET_CAPS_OUT_MATCH_FIELD_COUNT); in efx_mae_get_basic_caps()
485 caps->encap_types = MCDI_DWORD(outbuf, MAE_GET_CAPS_OUT_ENCAP_TYPES_SUPPORTED); in efx_mae_get_basic_caps()
486 caps->action_prios = MCDI_DWORD(outbuf, MAE_GET_CAPS_OUT_ACTION_PRIOS); in efx_mae_get_basic_caps()
534 caps->action_rule_fields); in efx_mae_get_caps()
538 caps->outer_rule_fields); in efx_mae_get_caps()
555 return "all-1s"; in mask_type_name()
557 return "all-0s"; in mask_type_name()
567 /* Checks a (big-endian) bytestring is a bit prefix */
603 return -EOPNOTSUPP; in efx_mae_match_check_cap_typ()
611 return -EINVAL; in efx_mae_match_check_cap_typ()
614 return -EOPNOTSUPP; in efx_mae_match_check_cap_typ()
619 return -EIO; in efx_mae_match_check_cap_typ()
625 enum mask_type typ = classify_mask((const u8 *)&mask->_field, \
626 sizeof(mask->_field)); \
638 enum mask_type typ = mask->_field ? MASK_ONES : MASK_ZEROES; \
653 const u8 *supported_fields = efx->tc->caps->action_rule_fields; in efx_mae_match_check_caps()
654 __be32 ingress_port = cpu_to_be32(mask->ingress_port); in efx_mae_match_check_caps()
658 /* Check for _PREFIX assumes big-endian, so we need to convert */ in efx_mae_match_check_caps()
713 } else if (mask->enc_keyid) { in efx_mae_match_check_caps()
715 return -EINVAL; in efx_mae_match_check_caps()
722 enum mask_type typ = classify_mask((const u8 *)&mask->_field, \
723 sizeof(mask->_field)); \
727 rc = -EOPNOTSUPP; \
732 if (mask->_field) { \
734 rc = -EOPNOTSUPP; \
747 const u8 *supported_fields = efx->tc->caps->outer_rule_fields; in efx_mae_match_check_caps_lhs()
748 __be32 ingress_port = cpu_to_be32(mask->ingress_port); in efx_mae_match_check_caps_lhs()
752 /* Check for _PREFIX assumes big-endian, so we need to convert */ in efx_mae_match_check_caps_lhs()
791 return -EOPNOTSUPP; in efx_mae_match_check_caps_lhs()
814 /* Checks that the fields needed for encap-rule matches are supported by the
815 * MAE. All the fields are exact-match, except possibly ENC_IP_TOS.
821 u8 *supported_fields = efx->tc->caps->outer_rule_fields; in efx_mae_check_encap_match_caps()
871 return -EOPNOTSUPP; in efx_mae_check_encap_type_supported()
873 if (efx->tc->caps->encap_types & BIT(bit)) in efx_mae_check_encap_type_supported()
875 return -EOPNOTSUPP; in efx_mae_check_encap_type_supported()
886 return -EINVAL; in efx_mae_allocate_counter()
889 MCDI_SET_DWORD(inbuf, MAE_COUNTER_ALLOC_V2_IN_COUNTER_TYPE, cnt->type); in efx_mae_allocate_counter()
896 return -EIO; in efx_mae_allocate_counter()
897 cnt->fw_id = MCDI_DWORD(outbuf, MAE_COUNTER_ALLOC_OUT_COUNTER_ID); in efx_mae_allocate_counter()
898 cnt->gen = MCDI_DWORD(outbuf, MAE_COUNTER_ALLOC_OUT_GENERATION_COUNT); in efx_mae_allocate_counter()
910 MCDI_SET_DWORD(inbuf, MAE_COUNTER_FREE_V2_IN_FREE_COUNTER_ID, cnt->fw_id); in efx_mae_free_counter()
911 MCDI_SET_DWORD(inbuf, MAE_COUNTER_FREE_V2_IN_COUNTER_TYPE, cnt->type); in efx_mae_free_counter()
918 return -EIO; in efx_mae_free_counter()
924 cnt->fw_id)) in efx_mae_free_counter()
925 return -EIO; in efx_mae_free_counter()
939 return -EOPNOTSUPP; in efx_mae_encap_type_to_mae_type()
951 rc = efx_mae_encap_type_to_mae_type(encap->type); in efx_mae_allocate_encap_md()
955 inlen = MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_LEN(encap->encap_hdr_len); in efx_mae_allocate_encap_md()
957 return -EINVAL; in efx_mae_allocate_encap_md()
959 encap->encap_hdr, in efx_mae_allocate_encap_md()
960 encap->encap_hdr_len); in efx_mae_allocate_encap_md()
966 return -EIO; in efx_mae_allocate_encap_md()
967 encap->fw_id = MCDI_DWORD(outbuf, MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID); in efx_mae_allocate_encap_md()
978 rc = efx_mae_encap_type_to_mae_type(encap->type); in efx_mae_update_encap_md()
983 encap->fw_id); in efx_mae_update_encap_md()
984 inlen = MC_CMD_MAE_ENCAP_HEADER_UPDATE_IN_LEN(encap->encap_hdr_len); in efx_mae_update_encap_md()
986 return -EINVAL; in efx_mae_update_encap_md()
988 encap->encap_hdr, in efx_mae_update_encap_md()
989 encap->encap_hdr_len); in efx_mae_update_encap_md()
1004 MCDI_SET_DWORD(inbuf, MAE_ENCAP_HEADER_FREE_IN_EH_ID, encap->fw_id); in efx_mae_free_encap_md()
1010 return -EIO; in efx_mae_free_encap_md()
1015 if (WARN_ON(MCDI_DWORD(outbuf, MAE_ENCAP_HEADER_FREE_OUT_FREED_EH_ID) != encap->fw_id)) in efx_mae_free_encap_md()
1016 return -EIO; in efx_mae_free_encap_md()
1020 encap->fw_id = MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_NULL; in efx_mae_free_encap_md()
1026 struct ef100_nic_data *nic_data = efx->nic_data; in efx_mae_lookup_mport()
1027 struct efx_mae *mae = efx->mae; in efx_mae_lookup_mport()
1030 int rc = -ENOENT; in efx_mae_lookup_mport()
1032 rhashtable_walk_enter(&mae->mports_ht, &walk); in efx_mae_lookup_mport()
1035 if (m->mport_type == MAE_MPORT_DESC_MPORT_TYPE_VNIC && in efx_mae_lookup_mport()
1036 m->interface_idx == nic_data->local_mae_intf && in efx_mae_lookup_mport()
1037 m->pf_idx == 0 && in efx_mae_lookup_mport()
1038 m->vf_idx == vf_idx) { in efx_mae_lookup_mport()
1039 *id = m->mport_id; in efx_mae_lookup_mport()
1063 return rhashtable_lookup_fast(&efx->mae->mports_ht, &mport_id, in efx_mae_get_mport()
1069 struct efx_mae *mae = efx->mae; in efx_mae_add_mport()
1072 rc = rhashtable_insert_fast(&mae->mports_ht, &desc->linkage, in efx_mae_add_mport()
1076 pci_err(efx->pci_dev, "Failed to insert MPORT %08x, rc %d\n", in efx_mae_add_mport()
1077 desc->mport_id, rc); in efx_mae_add_mport()
1096 struct ef100_nic_data *nic_data = efx->nic_data; in efx_mae_process_mport()
1099 mport = efx_mae_get_mport(efx, desc->mport_id); in efx_mae_process_mport()
1101 netif_err(efx, drv, efx->net_dev, in efx_mae_process_mport()
1102 "mport with id %u does exist!!!\n", desc->mport_id); in efx_mae_process_mport()
1103 return -EEXIST; in efx_mae_process_mport()
1106 if (nic_data->have_own_mport && in efx_mae_process_mport()
1107 desc->mport_id == nic_data->own_mport) { in efx_mae_process_mport()
1108 WARN_ON(desc->mport_type != MAE_MPORT_DESC_MPORT_TYPE_VNIC); in efx_mae_process_mport()
1109 WARN_ON(desc->vnic_client_type != in efx_mae_process_mport()
1111 nic_data->local_mae_intf = desc->interface_idx; in efx_mae_process_mport()
1112 nic_data->have_local_intf = true; in efx_mae_process_mport()
1113 pci_dbg(efx->pci_dev, "MAE interface_idx is %u\n", in efx_mae_process_mport()
1114 nic_data->local_mae_intf); in efx_mae_process_mport()
1128 size_t outlen, stride, count; in efx_mae_enumerate_mports() local
1132 return -ENOMEM; in efx_mae_enumerate_mports()
1140 rc = -EIO; in efx_mae_enumerate_mports()
1146 stride = MCDI_DWORD(outbuf, MAE_MPORT_READ_JOURNAL_OUT_SIZEOF_MPORT_DESC); in efx_mae_enumerate_mports()
1147 if (stride < MAE_MPORT_DESC_LEN) { in efx_mae_enumerate_mports()
1148 rc = -EIO; in efx_mae_enumerate_mports()
1151 if (outlen < MC_CMD_MAE_MPORT_READ_JOURNAL_OUT_LEN(count * stride)) { in efx_mae_enumerate_mports()
1152 rc = -EIO; in efx_mae_enumerate_mports()
1161 rc = -ENOMEM; in efx_mae_enumerate_mports()
1167 i * stride); in efx_mae_enumerate_mports()
1168 d->mport_id = MCDI_STRUCT_DWORD(desc, MAE_MPORT_DESC_MPORT_ID); in efx_mae_enumerate_mports()
1169 d->flags = MCDI_STRUCT_DWORD(desc, MAE_MPORT_DESC_FLAGS); in efx_mae_enumerate_mports()
1170 d->caller_flags = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1172 d->mport_type = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1174 switch (d->mport_type) { in efx_mae_enumerate_mports()
1176 d->port_idx = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1180 d->alias_mport_id = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1184 d->vnic_client_type = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1186 d->interface_idx = MCDI_STRUCT_DWORD(desc, in efx_mae_enumerate_mports()
1188 d->pf_idx = MCDI_STRUCT_WORD(desc, in efx_mae_enumerate_mports()
1190 d->vf_idx = MCDI_STRUCT_WORD(desc, in efx_mae_enumerate_mports()
1212 * efx_mae_allocate_pedit_mac() - allocate pedit MAC address in HW.
1230 sizeof(ped->h_addr)); in efx_mae_allocate_pedit_mac()
1231 memcpy(MCDI_PTR(inbuf, MAE_MAC_ADDR_ALLOC_IN_MAC_ADDR), ped->h_addr, in efx_mae_allocate_pedit_mac()
1232 sizeof(ped->h_addr)); in efx_mae_allocate_pedit_mac()
1238 return -EIO; in efx_mae_allocate_pedit_mac()
1239 ped->fw_id = MCDI_DWORD(outbuf, MAE_MAC_ADDR_ALLOC_OUT_MAC_ID); in efx_mae_allocate_pedit_mac()
1244 * efx_mae_free_pedit_mac() - free pedit MAC address in HW.
1259 MCDI_SET_DWORD(inbuf, MAE_MAC_ADDR_FREE_IN_MAC_ID, ped->fw_id); in efx_mae_free_pedit_mac()
1268 if (WARN_ON(MCDI_DWORD(outbuf, MAE_MAC_ADDR_FREE_OUT_FREED_MAC_ID) != ped->fw_id)) in efx_mae_free_pedit_mac()
1273 ped->fw_id = MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL; in efx_mae_free_pedit_mac()
1284 MAE_ACTION_SET_ALLOC_IN_VLAN_PUSH, act->vlan_push, in efx_mae_alloc_action_set()
1285 MAE_ACTION_SET_ALLOC_IN_VLAN_POP, act->vlan_pop, in efx_mae_alloc_action_set()
1286 MAE_ACTION_SET_ALLOC_IN_DECAP, act->decap, in efx_mae_alloc_action_set()
1287 MAE_ACTION_SET_ALLOC_IN_DO_NAT, act->do_nat, in efx_mae_alloc_action_set()
1289 act->do_ttl_dec); in efx_mae_alloc_action_set()
1291 if (act->src_mac) in efx_mae_alloc_action_set()
1293 act->src_mac->fw_id); in efx_mae_alloc_action_set()
1298 if (act->dst_mac) in efx_mae_alloc_action_set()
1300 act->dst_mac->fw_id); in efx_mae_alloc_action_set()
1305 if (act->count && !WARN_ON(!act->count->cnt)) in efx_mae_alloc_action_set()
1307 act->count->cnt->fw_id); in efx_mae_alloc_action_set()
1313 if (act->vlan_push) { in efx_mae_alloc_action_set()
1315 act->vlan_tci[0]); in efx_mae_alloc_action_set()
1317 act->vlan_proto[0]); in efx_mae_alloc_action_set()
1319 if (act->vlan_push >= 2) { in efx_mae_alloc_action_set()
1321 act->vlan_tci[1]); in efx_mae_alloc_action_set()
1323 act->vlan_proto[1]); in efx_mae_alloc_action_set()
1325 if (act->encap_md) in efx_mae_alloc_action_set()
1327 act->encap_md->fw_id); in efx_mae_alloc_action_set()
1331 if (act->deliver) in efx_mae_alloc_action_set()
1333 act->dest_mport); in efx_mae_alloc_action_set()
1340 return -EIO; in efx_mae_alloc_action_set()
1341 act->fw_id = MCDI_DWORD(outbuf, MAE_ACTION_SET_ALLOC_OUT_AS_ID); in efx_mae_alloc_action_set()
1345 if (WARN_ON_ONCE(efx_mae_asl_id(act->fw_id))) { in efx_mae_alloc_action_set()
1346 efx_mae_free_action_set(efx, act->fw_id); in efx_mae_alloc_action_set()
1347 return -EIO; in efx_mae_alloc_action_set()
1365 return -EIO; in efx_mae_free_action_set()
1368 * what action-sets exist, which could cause mayhem later. in efx_mae_free_action_set()
1371 return -EIO; in efx_mae_free_action_set()
1384 list_for_each_entry(act, &acts->list, list) in efx_mae_alloc_action_set_list()
1387 return -EINVAL; in efx_mae_alloc_action_set_list()
1392 act = list_first_entry(&acts->list, struct efx_tc_action_set, list); in efx_mae_alloc_action_set_list()
1393 acts->fw_id = act->fw_id; in efx_mae_alloc_action_set_list()
1397 return -EOPNOTSUPP; /* Too many actions */ in efx_mae_alloc_action_set_list()
1401 return -ENOMEM; in efx_mae_alloc_action_set_list()
1403 list_for_each_entry(act, &acts->list, list) { in efx_mae_alloc_action_set_list()
1405 i, act->fw_id); in efx_mae_alloc_action_set_list()
1414 rc = -EIO; in efx_mae_alloc_action_set_list()
1417 acts->fw_id = MCDI_DWORD(outbuf, MAE_ACTION_SET_LIST_ALLOC_OUT_ASL_ID); in efx_mae_alloc_action_set_list()
1421 if (WARN_ON_ONCE(!efx_mae_asl_id(acts->fw_id))) { in efx_mae_alloc_action_set_list()
1423 rc = -EIO; in efx_mae_alloc_action_set_list()
1441 if (efx_mae_asl_id(acts->fw_id)) { in efx_mae_free_action_set_list()
1443 acts->fw_id); in efx_mae_free_action_set_list()
1449 return -EIO; in efx_mae_free_action_set_list()
1452 * what action-set-lists exist, which could cause mayhem later. in efx_mae_free_action_set_list()
1454 if (WARN_ON(MCDI_DWORD(outbuf, MAE_ACTION_SET_LIST_FREE_OUT_FREED_ASL_ID) != acts->fw_id)) in efx_mae_free_action_set_list()
1455 return -EIO; in efx_mae_free_action_set_list()
1460 acts->fw_id = MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_ACTION_SET_LIST_ID_NULL; in efx_mae_free_action_set_list()
1473 rc = efx_mae_encap_type_to_mae_type(encap->tun_type); in efx_mae_register_encap_match()
1483 if (encap->src_ip | encap->dst_ip) { in efx_mae_register_encap_match()
1486 encap->src_ip); in efx_mae_register_encap_match()
1490 encap->dst_ip); in efx_mae_register_encap_match()
1498 &encap->src_ip6, sizeof(encap->src_ip6)); in efx_mae_register_encap_match()
1500 0xff, sizeof(encap->src_ip6)); in efx_mae_register_encap_match()
1502 &encap->dst_ip6, sizeof(encap->dst_ip6)); in efx_mae_register_encap_match()
1504 0xff, sizeof(encap->dst_ip6)); in efx_mae_register_encap_match()
1512 encap->udp_dport); in efx_mae_register_encap_match()
1516 encap->udp_sport); in efx_mae_register_encap_match()
1518 encap->udp_sport_mask); in efx_mae_register_encap_match()
1522 encap->ip_tos); in efx_mae_register_encap_match()
1524 encap->ip_tos_mask); in efx_mae_register_encap_match()
1530 return -EIO; in efx_mae_register_encap_match()
1531 encap->fw_id = MCDI_DWORD(outbuf, MAE_OUTER_RULE_INSERT_OUT_OR_ID); in efx_mae_register_encap_match()
1543 MCDI_SET_DWORD(inbuf, MAE_OUTER_RULE_REMOVE_IN_OR_ID, encap->fw_id); in efx_mae_unregister_encap_match()
1549 return -EIO; in efx_mae_unregister_encap_match()
1554 if (WARN_ON(MCDI_DWORD(outbuf, MAE_OUTER_RULE_REMOVE_OUT_REMOVED_OR_ID) != encap->fw_id)) in efx_mae_unregister_encap_match()
1555 return -EIO; in efx_mae_unregister_encap_match()
1559 encap->fw_id = MC_CMD_MAE_OUTER_RULE_INSERT_OUT_OUTER_RULE_ID_NULL; in efx_mae_unregister_encap_match()
1566 if (match->mask.ingress_port) { in efx_mae_populate_lhs_match_criteria()
1567 if (~match->mask.ingress_port) in efx_mae_populate_lhs_match_criteria()
1568 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1571 match->value.ingress_port); in efx_mae_populate_lhs_match_criteria()
1574 match->mask.ingress_port); in efx_mae_populate_lhs_match_criteria()
1576 match->value.eth_proto); in efx_mae_populate_lhs_match_criteria()
1578 match->mask.eth_proto); in efx_mae_populate_lhs_match_criteria()
1580 match->value.vlan_tci[0]); in efx_mae_populate_lhs_match_criteria()
1582 match->mask.vlan_tci[0]); in efx_mae_populate_lhs_match_criteria()
1584 match->value.vlan_proto[0]); in efx_mae_populate_lhs_match_criteria()
1586 match->mask.vlan_proto[0]); in efx_mae_populate_lhs_match_criteria()
1588 match->value.vlan_tci[1]); in efx_mae_populate_lhs_match_criteria()
1590 match->mask.vlan_tci[1]); in efx_mae_populate_lhs_match_criteria()
1592 match->value.vlan_proto[1]); in efx_mae_populate_lhs_match_criteria()
1594 match->mask.vlan_proto[1]); in efx_mae_populate_lhs_match_criteria()
1596 match->value.eth_saddr, ETH_ALEN); in efx_mae_populate_lhs_match_criteria()
1598 match->mask.eth_saddr, ETH_ALEN); in efx_mae_populate_lhs_match_criteria()
1600 match->value.eth_daddr, ETH_ALEN); in efx_mae_populate_lhs_match_criteria()
1602 match->mask.eth_daddr, ETH_ALEN); in efx_mae_populate_lhs_match_criteria()
1604 match->value.ip_proto); in efx_mae_populate_lhs_match_criteria()
1606 match->mask.ip_proto); in efx_mae_populate_lhs_match_criteria()
1608 match->value.ip_tos); in efx_mae_populate_lhs_match_criteria()
1610 match->mask.ip_tos); in efx_mae_populate_lhs_match_criteria()
1612 match->value.ip_ttl); in efx_mae_populate_lhs_match_criteria()
1614 match->mask.ip_ttl); in efx_mae_populate_lhs_match_criteria()
1618 match->value.ip_frag); in efx_mae_populate_lhs_match_criteria()
1622 match->mask.ip_frag); in efx_mae_populate_lhs_match_criteria()
1624 match->value.src_ip); in efx_mae_populate_lhs_match_criteria()
1626 match->mask.src_ip); in efx_mae_populate_lhs_match_criteria()
1628 match->value.dst_ip); in efx_mae_populate_lhs_match_criteria()
1630 match->mask.dst_ip); in efx_mae_populate_lhs_match_criteria()
1633 &match->value.src_ip6, sizeof(struct in6_addr)); in efx_mae_populate_lhs_match_criteria()
1635 &match->mask.src_ip6, sizeof(struct in6_addr)); in efx_mae_populate_lhs_match_criteria()
1637 &match->value.dst_ip6, sizeof(struct in6_addr)); in efx_mae_populate_lhs_match_criteria()
1639 &match->mask.dst_ip6, sizeof(struct in6_addr)); in efx_mae_populate_lhs_match_criteria()
1642 match->value.l4_sport); in efx_mae_populate_lhs_match_criteria()
1644 match->mask.l4_sport); in efx_mae_populate_lhs_match_criteria()
1646 match->value.l4_dport); in efx_mae_populate_lhs_match_criteria()
1648 match->mask.l4_dport); in efx_mae_populate_lhs_match_criteria()
1649 /* No enc-keys in LHS rules. Caps check should have caught this; any in efx_mae_populate_lhs_match_criteria()
1650 * enc-keys from an fLHS should have been translated to regular keys in efx_mae_populate_lhs_match_criteria()
1654 if (WARN_ON_ONCE(match->encap && !match->encap->type)) in efx_mae_populate_lhs_match_criteria()
1655 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1656 if (WARN_ON_ONCE(match->mask.enc_src_ip)) in efx_mae_populate_lhs_match_criteria()
1657 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1658 if (WARN_ON_ONCE(match->mask.enc_dst_ip)) in efx_mae_populate_lhs_match_criteria()
1659 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1661 if (WARN_ON_ONCE(!ipv6_addr_any(&match->mask.enc_src_ip6))) in efx_mae_populate_lhs_match_criteria()
1662 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1663 if (WARN_ON_ONCE(!ipv6_addr_any(&match->mask.enc_dst_ip6))) in efx_mae_populate_lhs_match_criteria()
1664 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1666 if (WARN_ON_ONCE(match->mask.enc_ip_tos)) in efx_mae_populate_lhs_match_criteria()
1667 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1668 if (WARN_ON_ONCE(match->mask.enc_ip_ttl)) in efx_mae_populate_lhs_match_criteria()
1669 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1670 if (WARN_ON_ONCE(match->mask.enc_sport)) in efx_mae_populate_lhs_match_criteria()
1671 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1672 if (WARN_ON_ONCE(match->mask.enc_dport)) in efx_mae_populate_lhs_match_criteria()
1673 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1674 if (WARN_ON_ONCE(match->mask.enc_keyid)) in efx_mae_populate_lhs_match_criteria()
1675 return -EOPNOTSUPP; in efx_mae_populate_lhs_match_criteria()
1692 rc = efx_mae_populate_lhs_match_criteria(match_crit, &rule->match); in efx_mae_insert_lhs_outer_rule()
1697 act = &rule->lhs_act; in efx_mae_insert_lhs_outer_rule()
1698 rc = efx_mae_encap_type_to_mae_type(act->tun_type); in efx_mae_insert_lhs_outer_rule()
1707 MAE_OUTER_RULE_INSERT_IN_DO_CT, !!act->zone, in efx_mae_insert_lhs_outer_rule()
1710 act->zone ? act->zone->zone : 0, in efx_mae_insert_lhs_outer_rule()
1713 MAE_OUTER_RULE_INSERT_IN_DO_COUNT, !!act->count, in efx_mae_insert_lhs_outer_rule()
1715 act->rid ? act->rid->fw_id : 0); in efx_mae_insert_lhs_outer_rule()
1716 if (act->count) in efx_mae_insert_lhs_outer_rule()
1718 act->count->cnt->fw_id); in efx_mae_insert_lhs_outer_rule()
1724 return -EIO; in efx_mae_insert_lhs_outer_rule()
1725 rule->fw_id = MCDI_DWORD(outbuf, MAE_OUTER_RULE_INSERT_OUT_OR_ID); in efx_mae_insert_lhs_outer_rule()
1738 struct efx_tc_lhs_action *act = &rule->lhs_act; in efx_mae_insert_lhs_action_rule()
1751 MAE_ACTION_RULE_RESPONSE_DO_CT, !!act->zone, in efx_mae_insert_lhs_action_rule()
1753 act->rid && !act->zone, in efx_mae_insert_lhs_action_rule()
1757 act->rid ? act->rid->fw_id : 0, in efx_mae_insert_lhs_action_rule()
1759 act->zone ? act->zone->zone : 0); in efx_mae_insert_lhs_action_rule()
1761 act->count ? act->count->cnt->fw_id : in efx_mae_insert_lhs_action_rule()
1764 rc = efx_mae_populate_match_criteria(match_crit, &rule->match); in efx_mae_insert_lhs_action_rule()
1773 return -EIO; in efx_mae_insert_lhs_action_rule()
1774 rule->fw_id = MCDI_DWORD(outbuf, MAE_ACTION_RULE_INSERT_OUT_AR_ID); in efx_mae_insert_lhs_action_rule()
1781 if (rule->is_ar) in efx_mae_insert_lhs_rule()
1794 MCDI_SET_DWORD(inbuf, MAE_OUTER_RULE_REMOVE_IN_OR_ID, rule->fw_id); in efx_mae_remove_lhs_outer_rule()
1800 return -EIO; in efx_mae_remove_lhs_outer_rule()
1805 if (WARN_ON(MCDI_DWORD(outbuf, MAE_OUTER_RULE_REMOVE_OUT_REMOVED_OR_ID) != rule->fw_id)) in efx_mae_remove_lhs_outer_rule()
1806 return -EIO; in efx_mae_remove_lhs_outer_rule()
1810 rule->fw_id = MC_CMD_MAE_OUTER_RULE_INSERT_OUT_OUTER_RULE_ID_NULL; in efx_mae_remove_lhs_outer_rule()
1816 if (rule->is_ar) in efx_mae_remove_lhs_rule()
1817 return efx_mae_delete_rule(efx, rule->fw_id); in efx_mae_remove_lhs_rule()
1822 * it in the appropriate bits of @row. @value must be big-endian; we
1823 * convert it to little-endianness as we go.
1826 __le32 *row, size_t row_bits, in efx_mae_table_populate() argument
1836 return -EOPNOTSUPP; in efx_mae_table_populate()
1838 return -EINVAL; in efx_mae_table_populate()
1840 return -EINVAL; in efx_mae_table_populate()
1846 v = ((u8 *)value)[value_size - i - 1]; in efx_mae_table_populate()
1848 row[wn] |= cpu_to_le32(v & 0xffffffff); in efx_mae_table_populate()
1850 row[wn + 1] |= cpu_to_le32(v >> 32); in efx_mae_table_populate()
1856 __le32 *row, size_t row_bits, bool value) in efx_mae_table_populate_bool() argument
1861 return -EINVAL; in efx_mae_table_populate_bool()
1862 return efx_mae_table_populate(field, row, row_bits, &v, 1); in efx_mae_table_populate_bool()
1866 __le32 *row, size_t row_bits, __be32 value) in efx_mae_table_populate_ipv4() argument
1868 /* IPv4 is placed in the first 4 bytes of an IPv6-sized field */ in efx_mae_table_populate_ipv4()
1872 return -EINVAL; in efx_mae_table_populate_ipv4()
1874 return efx_mae_table_populate(field, row, row_bits, &v, sizeof(v)); in efx_mae_table_populate_ipv4()
1878 __le32 *row, size_t row_bits, u32 value) in efx_mae_table_populate_u24() argument
1884 * the most significant byte for a big-endian 4-bytes value. in efx_mae_table_populate_u24()
1886 return efx_mae_table_populate(field, row, row_bits, ((void *)&v) + 1, in efx_mae_table_populate_u24()
1887 sizeof(v) - 1); in efx_mae_table_populate_u24()
1895 sizeof(_v)) : -EINVAL; \
1898 efx_mae_table_populate_ipv4(efx->tc->meta_##_table.desc.keys \
1899 [efx->tc->meta_##_table.keys._field##_idx],\
1900 dst, efx->tc->meta_##_table.desc.key_width,\
1903 _TABLE_POPULATE(dst, efx->tc->meta_##_table.desc.key_width, \
1904 efx->tc->meta_##_table.desc.keys \
1905 [efx->tc->meta_##_table.keys._field##_idx], \
1909 efx_mae_table_populate_bool(efx->tc->meta_##_table.desc.resps \
1910 [efx->tc->meta_##_table.resps._field##_idx],\
1911 dst, efx->tc->meta_##_table.desc.resp_width,\
1914 _TABLE_POPULATE(dst, efx->tc->meta_##_table.desc.resp_width, \
1915 efx->tc->meta_##_table.desc.resps \
1916 [efx->tc->meta_##_table.resps._field##_idx], \
1920 efx_mae_table_populate_u24(efx->tc->meta_##_table.desc.resps \
1921 [efx->tc->meta_##_table.resps._field##_idx],\
1922 dst, efx->tc->meta_##_table.desc.resp_width,\
1928 bool ipv6 = conn->eth_proto == htons(ETH_P_IPV6); in efx_mae_populate_ct_key()
1931 rc = TABLE_POPULATE_KEY(key, ct, eth_proto, conn->eth_proto); in efx_mae_populate_ct_key()
1934 rc = TABLE_POPULATE_KEY(key, ct, ip_proto, conn->ip_proto); in efx_mae_populate_ct_key()
1938 rc = TABLE_POPULATE_KEY(key, ct, src_ip, conn->src_ip6); in efx_mae_populate_ct_key()
1940 rc = TABLE_POPULATE_KEY_IPV4(key, ct, src_ip, conn->src_ip); in efx_mae_populate_ct_key()
1944 rc = TABLE_POPULATE_KEY(key, ct, dst_ip, conn->dst_ip6); in efx_mae_populate_ct_key()
1946 rc = TABLE_POPULATE_KEY_IPV4(key, ct, dst_ip, conn->dst_ip); in efx_mae_populate_ct_key()
1949 rc = TABLE_POPULATE_KEY(key, ct, l4_sport, conn->l4_sport); in efx_mae_populate_ct_key()
1952 rc = TABLE_POPULATE_KEY(key, ct, l4_dport, conn->l4_dport); in efx_mae_populate_ct_key()
1955 return TABLE_POPULATE_KEY(key, ct, zone, cpu_to_be16(conn->zone->zone)); in efx_mae_populate_ct_key()
1960 bool ipv6 = conn->eth_proto == htons(ETH_P_IPV6); in efx_mae_insert_ct()
1964 int rc = -ENOMEM; in efx_mae_insert_ct()
1967 if (!efx->tc->meta_ct.hooked) in efx_mae_insert_ct()
1968 return -EOPNOTSUPP; in efx_mae_insert_ct()
1971 kw = DIV_ROUND_UP(efx->tc->meta_ct.desc.key_width, 32); in efx_mae_insert_ct()
1972 rw = DIV_ROUND_UP(efx->tc->meta_ct.desc.resp_width, 32); in efx_mae_insert_ct()
1976 return -E2BIG; in efx_mae_insert_ct()
1979 return -ENOMEM; in efx_mae_insert_ct()
1992 rc = TABLE_POPULATE_RESP_BOOL(resp, ct, dnat, conn->dnat); in efx_mae_insert_ct()
1997 rc = TABLE_POPULATE_RESP(resp, ct, nat_ip, conn->nat_ip); in efx_mae_insert_ct()
2000 rc = TABLE_POPULATE_RESP(resp, ct, l4_natport, conn->l4_natport); in efx_mae_insert_ct()
2003 rc = TABLE_POPULATE_RESP(resp, ct, mark, cpu_to_be32(conn->mark)); in efx_mae_insert_ct()
2006 rc = TABLE_POPULATE_RESP_U24(resp, ct, counter_id, conn->cnt->fw_id); in efx_mae_insert_ct()
2012 efx->tc->meta_ct.desc.key_width); in efx_mae_insert_ct()
2015 efx->tc->meta_ct.desc.resp_width); in efx_mae_insert_ct()
2036 int rc = -ENOMEM; in efx_mae_remove_ct()
2039 if (!efx->tc->meta_ct.hooked) in efx_mae_remove_ct()
2040 return -EOPNOTSUPP; in efx_mae_remove_ct()
2043 kw = DIV_ROUND_UP(efx->tc->meta_ct.desc.key_width, 32); in efx_mae_remove_ct()
2047 return -E2BIG; in efx_mae_remove_ct()
2050 return -ENOMEM; in efx_mae_remove_ct()
2062 efx->tc->meta_ct.desc.key_width); in efx_mae_remove_ct()
2080 if (match->mask.ingress_port) { in efx_mae_populate_match_criteria()
2081 if (~match->mask.ingress_port) in efx_mae_populate_match_criteria()
2082 return -EOPNOTSUPP; in efx_mae_populate_match_criteria()
2085 match->value.ingress_port); in efx_mae_populate_match_criteria()
2088 match->mask.ingress_port); in efx_mae_populate_match_criteria()
2091 match->value.ct_state_trk, in efx_mae_populate_match_criteria()
2093 match->value.ct_state_est, in efx_mae_populate_match_criteria()
2095 match->value.ip_frag, in efx_mae_populate_match_criteria()
2097 match->value.ip_firstfrag, in efx_mae_populate_match_criteria()
2099 match->value.tcp_syn_fin_rst); in efx_mae_populate_match_criteria()
2102 match->mask.ct_state_trk, in efx_mae_populate_match_criteria()
2104 match->mask.ct_state_est, in efx_mae_populate_match_criteria()
2106 match->mask.ip_frag, in efx_mae_populate_match_criteria()
2108 match->mask.ip_firstfrag, in efx_mae_populate_match_criteria()
2110 match->mask.tcp_syn_fin_rst); in efx_mae_populate_match_criteria()
2112 match->value.recirc_id); in efx_mae_populate_match_criteria()
2114 match->mask.recirc_id); in efx_mae_populate_match_criteria()
2116 match->value.ct_mark); in efx_mae_populate_match_criteria()
2118 match->mask.ct_mark); in efx_mae_populate_match_criteria()
2120 match->value.ct_zone); in efx_mae_populate_match_criteria()
2122 match->mask.ct_zone); in efx_mae_populate_match_criteria()
2124 match->value.eth_proto); in efx_mae_populate_match_criteria()
2126 match->mask.eth_proto); in efx_mae_populate_match_criteria()
2128 match->value.vlan_tci[0]); in efx_mae_populate_match_criteria()
2130 match->mask.vlan_tci[0]); in efx_mae_populate_match_criteria()
2132 match->value.vlan_proto[0]); in efx_mae_populate_match_criteria()
2134 match->mask.vlan_proto[0]); in efx_mae_populate_match_criteria()
2136 match->value.vlan_tci[1]); in efx_mae_populate_match_criteria()
2138 match->mask.vlan_tci[1]); in efx_mae_populate_match_criteria()
2140 match->value.vlan_proto[1]); in efx_mae_populate_match_criteria()
2142 match->mask.vlan_proto[1]); in efx_mae_populate_match_criteria()
2144 match->value.eth_saddr, ETH_ALEN); in efx_mae_populate_match_criteria()
2146 match->mask.eth_saddr, ETH_ALEN); in efx_mae_populate_match_criteria()
2148 match->value.eth_daddr, ETH_ALEN); in efx_mae_populate_match_criteria()
2150 match->mask.eth_daddr, ETH_ALEN); in efx_mae_populate_match_criteria()
2152 match->value.ip_proto); in efx_mae_populate_match_criteria()
2154 match->mask.ip_proto); in efx_mae_populate_match_criteria()
2156 match->value.ip_tos); in efx_mae_populate_match_criteria()
2158 match->mask.ip_tos); in efx_mae_populate_match_criteria()
2160 match->value.ip_ttl); in efx_mae_populate_match_criteria()
2162 match->mask.ip_ttl); in efx_mae_populate_match_criteria()
2164 match->value.src_ip); in efx_mae_populate_match_criteria()
2166 match->mask.src_ip); in efx_mae_populate_match_criteria()
2168 match->value.dst_ip); in efx_mae_populate_match_criteria()
2170 match->mask.dst_ip); in efx_mae_populate_match_criteria()
2173 &match->value.src_ip6, sizeof(struct in6_addr)); in efx_mae_populate_match_criteria()
2175 &match->mask.src_ip6, sizeof(struct in6_addr)); in efx_mae_populate_match_criteria()
2177 &match->value.dst_ip6, sizeof(struct in6_addr)); in efx_mae_populate_match_criteria()
2179 &match->mask.dst_ip6, sizeof(struct in6_addr)); in efx_mae_populate_match_criteria()
2182 match->value.l4_sport); in efx_mae_populate_match_criteria()
2184 match->mask.l4_sport); in efx_mae_populate_match_criteria()
2186 match->value.l4_dport); in efx_mae_populate_match_criteria()
2188 match->mask.l4_dport); in efx_mae_populate_match_criteria()
2190 match->value.tcp_flags); in efx_mae_populate_match_criteria()
2192 match->mask.tcp_flags); in efx_mae_populate_match_criteria()
2193 /* enc-keys are handled indirectly, through encap_match ID */ in efx_mae_populate_match_criteria()
2194 if (match->encap) { in efx_mae_populate_match_criteria()
2196 match->encap->fw_id); in efx_mae_populate_match_criteria()
2201 match->value.enc_keyid); in efx_mae_populate_match_criteria()
2203 match->mask.enc_keyid); in efx_mae_populate_match_criteria()
2204 } else if (WARN_ON_ONCE(match->mask.enc_src_ip) || in efx_mae_populate_match_criteria()
2205 WARN_ON_ONCE(match->mask.enc_dst_ip) || in efx_mae_populate_match_criteria()
2206 WARN_ON_ONCE(!ipv6_addr_any(&match->mask.enc_src_ip6)) || in efx_mae_populate_match_criteria()
2207 WARN_ON_ONCE(!ipv6_addr_any(&match->mask.enc_dst_ip6)) || in efx_mae_populate_match_criteria()
2208 WARN_ON_ONCE(match->mask.enc_ip_tos) || in efx_mae_populate_match_criteria()
2209 WARN_ON_ONCE(match->mask.enc_ip_ttl) || in efx_mae_populate_match_criteria()
2210 WARN_ON_ONCE(match->mask.enc_sport) || in efx_mae_populate_match_criteria()
2211 WARN_ON_ONCE(match->mask.enc_dport) || in efx_mae_populate_match_criteria()
2212 WARN_ON_ONCE(match->mask.enc_keyid)) { in efx_mae_populate_match_criteria()
2213 /* No enc-keys should appear in a rule without an encap_match */ in efx_mae_populate_match_criteria()
2214 return -EOPNOTSUPP; in efx_mae_populate_match_criteria()
2230 return -EINVAL; in efx_mae_insert_rule()
2254 return -EIO; in efx_mae_insert_rule()
2295 return -EIO; in efx_mae_delete_rule()
2301 return -EIO; in efx_mae_delete_rule()
2307 struct ef100_nic_data *nic_data = efx->nic_data; in efx_init_mae()
2311 if (!nic_data->have_mport) in efx_init_mae()
2312 return -EINVAL; in efx_init_mae()
2316 return -ENOMEM; in efx_init_mae()
2318 rc = rhashtable_init(&mae->mports_ht, &efx_mae_mports_ht_params); in efx_init_mae()
2323 efx->mae = mae; in efx_init_mae()
2324 mae->efx = efx; in efx_init_mae()
2330 struct efx_mae *mae = efx->mae; in efx_fini_mae()
2333 efx->mae = NULL; in efx_fini_mae()