X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fiavf%2Fiavf_fdir.c;h=4e864b4b9ce291d6bf86baca9d1cd9635c52d220;hb=6c7f491e7fee0708e33b2e7e45c712db7a69c1d3;hp=1e50a07734d58993422914842097f65484a6b96f;hpb=6fb63b1a4df9c142721d24247edae38af65bf063;p=dpdk.git diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index 1e50a07734..4e864b4b9c 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -11,19 +11,23 @@ #include #include -#include +#include #include #include #include "iavf.h" #include "iavf_generic_flow.h" #include "virtchnl.h" +#include "iavf_rxtx.h" #define IAVF_FDIR_MAX_QREGION_SIZE 128 #define IAVF_FDIR_IPV6_TC_OFFSET 20 #define IAVF_IPV6_TC_MASK (0xFF << IAVF_FDIR_IPV6_TC_OFFSET) +#define IAVF_GTPU_EH_DWLINK 0 +#define IAVF_GTPU_EH_UPLINK 1 + #define IAVF_FDIR_INSET_ETH (\ IAVF_INSET_ETHERTYPE) @@ -67,14 +71,22 @@ IAVF_INSET_IPV6_TC | IAVF_INSET_IPV6_HOP_LIMIT | \ IAVF_INSET_SCTP_SRC_PORT | IAVF_INSET_SCTP_DST_PORT) -#define IAVF_FDIR_INSET_GTPU (\ +#define IAVF_FDIR_INSET_IPV4_GTPU (\ IAVF_INSET_IPV4_SRC | IAVF_INSET_IPV4_DST | \ IAVF_INSET_GTPU_TEID) -#define IAVF_FDIR_INSET_GTPU_EH (\ +#define IAVF_FDIR_INSET_IPV4_GTPU_EH (\ IAVF_INSET_IPV4_SRC | IAVF_INSET_IPV4_DST | \ IAVF_INSET_GTPU_TEID | IAVF_INSET_GTPU_QFI) +#define IAVF_FDIR_INSET_IPV6_GTPU (\ + IAVF_INSET_IPV6_SRC | IAVF_INSET_IPV6_DST | \ + IAVF_INSET_GTPU_TEID) + +#define IAVF_FDIR_INSET_IPV6_GTPU_EH (\ + IAVF_INSET_IPV6_SRC | IAVF_INSET_IPV6_DST | \ + IAVF_INSET_GTPU_TEID | IAVF_INSET_GTPU_QFI) + #define IAVF_FDIR_INSET_L2TPV3OIP (\ IAVF_L2TPV3OIP_SESSION_ID) @@ -95,6 +107,9 @@ #define IAVF_FDIR_INSET_PFCP (\ IAVF_INSET_PFCP_S_FIELD) +#define IAVF_FDIR_INSET_ECPRI (\ + IAVF_INSET_ECPRI) + static struct iavf_pattern_match_item iavf_fdir_pattern[] = { {iavf_pattern_ethertype, IAVF_FDIR_INSET_ETH, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4, IAVF_FDIR_INSET_ETH_IPV4, IAVF_INSET_NONE}, @@ -105,8 +120,10 @@ static struct iavf_pattern_match_item iavf_fdir_pattern[] = { {iavf_pattern_eth_ipv6_udp, IAVF_FDIR_INSET_ETH_IPV6_UDP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv6_tcp, IAVF_FDIR_INSET_ETH_IPV6_TCP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv6_sctp, IAVF_FDIR_INSET_ETH_IPV6_SCTP, IAVF_INSET_NONE}, - {iavf_pattern_eth_ipv4_gtpu, IAVF_FDIR_INSET_GTPU, IAVF_INSET_NONE}, - {iavf_pattern_eth_ipv4_gtpu_eh, IAVF_FDIR_INSET_GTPU_EH, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gtpu, IAVF_FDIR_INSET_IPV4_GTPU, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_gtpu_eh, IAVF_FDIR_INSET_IPV4_GTPU_EH, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gtpu, IAVF_FDIR_INSET_IPV6_GTPU, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv6_gtpu_eh, IAVF_FDIR_INSET_IPV6_GTPU_EH, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_l2tpv3, IAVF_FDIR_INSET_L2TPV3OIP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv6_l2tpv3, IAVF_FDIR_INSET_L2TPV3OIP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_esp, IAVF_FDIR_INSET_ESP, IAVF_INSET_NONE}, @@ -117,6 +134,8 @@ static struct iavf_pattern_match_item iavf_fdir_pattern[] = { {iavf_pattern_eth_ipv6_udp_esp, IAVF_FDIR_INSET_IPV6_NATT_ESP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv4_pfcp, IAVF_FDIR_INSET_PFCP, IAVF_INSET_NONE}, {iavf_pattern_eth_ipv6_pfcp, IAVF_FDIR_INSET_PFCP, IAVF_INSET_NONE}, + {iavf_pattern_eth_ecpri, IAVF_FDIR_INSET_ECPRI, IAVF_INSET_NONE}, + {iavf_pattern_eth_ipv4_ecpri, IAVF_FDIR_INSET_ECPRI, IAVF_INSET_NONE}, }; static struct iavf_flow_parser iavf_fdir_parser; @@ -170,6 +189,9 @@ iavf_fdir_create(struct iavf_adapter *ad, goto free_entry; } + if (filter->mark_flag == 1) + iavf_fdir_rx_proc_enable(ad, 1); + rte_memcpy(rule, filter, sizeof(*rule)); flow->rule = rule; @@ -198,6 +220,9 @@ iavf_fdir_destroy(struct iavf_adapter *ad, return -rte_errno; } + if (filter->mark_flag == 1) + iavf_fdir_rx_proc_enable(ad, 0); + flow->rule = NULL; rte_free(filter); @@ -239,6 +264,7 @@ iavf_fdir_parse_action_qregion(struct iavf_adapter *ad, const struct rte_flow_action *act, struct virtchnl_filter_action *filter_action) { + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); const struct rte_flow_action_rss *rss = act->conf; uint32_t i; @@ -283,6 +309,13 @@ iavf_fdir_parse_action_qregion(struct iavf_adapter *ad, return -rte_errno; } + if (rss->queue_num > vf->max_rss_qregion) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, act, + "The region size cannot be large than the supported max RSS queue region"); + return -rte_errno; + } + filter_action->act_conf.queue.index = rss->queue[0]; filter_action->act_conf.queue.region = rte_fls_u32(rss->queue_num) - 1; @@ -296,7 +329,9 @@ iavf_fdir_parse_action(struct iavf_adapter *ad, struct iavf_fdir_conf *filter) { const struct rte_flow_action_queue *act_q; + const struct rte_flow_action_mark *mark_spec = NULL; uint32_t dest_num = 0; + uint32_t mark_num = 0; int ret; int number = 0; @@ -362,6 +397,19 @@ iavf_fdir_parse_action(struct iavf_adapter *ad, filter->add_fltr.rule_cfg.action_set.count = ++number; break; + case RTE_FLOW_ACTION_TYPE_MARK: + mark_num++; + + filter->mark_flag = 1; + mark_spec = actions->conf; + filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; + + filter_action->type = VIRTCHNL_ACTION_MARK; + filter_action->act_conf.mark_id = mark_spec->id; + + filter->add_fltr.rule_cfg.action_set.count = ++number; + break; + default: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -377,19 +425,90 @@ iavf_fdir_parse_action(struct iavf_adapter *ad, return -rte_errno; } - if (dest_num == 0 || dest_num >= 2) { + if (dest_num >= 2) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "Unsupported action combination"); return -rte_errno; } + if (mark_num >= 2) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, actions, + "Too many mark actions"); + return -rte_errno; + } + + if (dest_num + mark_num == 0) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, actions, + "Empty action"); + return -rte_errno; + } + + /* Mark only is equal to mark + passthru. */ + if (dest_num == 0) { + filter_action = &filter->add_fltr.rule_cfg.action_set.actions[number]; + filter_action->type = VIRTCHNL_ACTION_PASSTHRU; + filter->add_fltr.rule_cfg.action_set.count = ++number; + } + return 0; } +static bool +iavf_fdir_refine_input_set(const uint64_t input_set, + const uint64_t input_set_mask, + struct iavf_fdir_conf *filter) +{ + struct virtchnl_proto_hdr *hdr, *hdr_last; + struct rte_flow_item_ipv4 ipv4_spec; + struct rte_flow_item_ipv6 ipv6_spec; + int last_layer; + uint8_t proto_id; + + if (input_set & ~input_set_mask) + return false; + else if (input_set) + return true; + + last_layer = filter->add_fltr.rule_cfg.proto_hdrs.count - 1; + /* Last layer of TCP/UDP pattern isn't less than 2. */ + if (last_layer < 2) + return false; + hdr_last = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer]; + if (hdr_last->type == VIRTCHNL_PROTO_HDR_TCP) + proto_id = 6; + else if (hdr_last->type == VIRTCHNL_PROTO_HDR_UDP) + proto_id = 17; + else + return false; + + hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[last_layer - 1]; + switch (hdr->type) { + case VIRTCHNL_PROTO_HDR_IPV4: + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, PROT); + memset(&ipv4_spec, 0, sizeof(ipv4_spec)); + ipv4_spec.hdr.next_proto_id = proto_id; + rte_memcpy(hdr->buffer, &ipv4_spec.hdr, + sizeof(ipv4_spec.hdr)); + return true; + case VIRTCHNL_PROTO_HDR_IPV6: + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, PROT); + memset(&ipv6_spec, 0, sizeof(ipv6_spec)); + ipv6_spec.hdr.proto = proto_id; + rte_memcpy(hdr->buffer, &ipv6_spec.hdr, + sizeof(ipv6_spec.hdr)); + return true; + default: + return false; + } +} + static int iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, const struct rte_flow_item pattern[], + const uint64_t input_set_mask, struct rte_flow_error *error, struct iavf_fdir_conf *filter) { @@ -408,6 +527,8 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, const struct rte_flow_item_esp *esp_spec, *esp_mask; const struct rte_flow_item_ah *ah_spec, *ah_mask; const struct rte_flow_item_pfcp *pfcp_spec, *pfcp_mask; + const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask; + struct rte_ecpri_common_hdr ecpri_common; uint64_t input_set = IAVF_INSET_NONE; enum rte_flow_item_type next_type; @@ -480,7 +601,7 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, ETH, ETHERTYPE); rte_memcpy(hdr->buffer, - eth_spec, sizeof(*eth_spec)); + eth_spec, sizeof(struct rte_ether_hdr)); } filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer; @@ -746,7 +867,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer]; - VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH); + if (!gtp_psc_spec) + VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH); + else if ((gtp_psc_mask->qfi) && !(gtp_psc_mask->pdu_type)) + VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH); + else if (gtp_psc_spec->pdu_type == IAVF_GTPU_EH_UPLINK) + VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH_PDU_UP); + else if (gtp_psc_spec->pdu_type == IAVF_GTPU_EH_DWLINK) + VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, GTPU_EH_PDU_DWN); if (gtp_psc_spec && gtp_psc_mask) { if (gtp_psc_mask->qfi == UINT8_MAX) { @@ -845,6 +973,31 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer; break; + case RTE_FLOW_ITEM_TYPE_ECPRI: + ecpri_spec = item->spec; + ecpri_mask = item->mask; + + ecpri_common.u32 = rte_be_to_cpu_32(ecpri_spec->hdr.common.u32); + + hdr = &filter->add_fltr.rule_cfg.proto_hdrs.proto_hdr[layer]; + + VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, ECPRI); + + if (ecpri_spec && ecpri_mask) { + if (ecpri_common.type == RTE_ECPRI_MSG_TYPE_IQ_DATA && + ecpri_mask->hdr.type0.pc_id == UINT16_MAX) { + input_set |= IAVF_ECPRI_PC_RTC_ID; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, ECPRI, + PC_RTC_ID); + } + + rte_memcpy(hdr->buffer, ecpri_spec, + sizeof(*ecpri_spec)); + } + + filter->add_fltr.rule_cfg.proto_hdrs.count = ++layer; + break; + case RTE_FLOW_ITEM_TYPE_VOID: break; @@ -863,6 +1016,13 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad, return -rte_errno; } + if (!iavf_fdir_refine_input_set(input_set, input_set_mask, filter)) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, + "Invalid input set"); + return -rte_errno; + } + filter->input_set = input_set; return 0; @@ -880,7 +1040,6 @@ iavf_fdir_parse(struct iavf_adapter *ad, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); struct iavf_fdir_conf *filter = &vf->fdir.conf; struct iavf_pattern_match_item *item = NULL; - uint64_t input_set; int ret; memset(filter, 0, sizeof(*filter)); @@ -889,19 +1048,11 @@ iavf_fdir_parse(struct iavf_adapter *ad, if (!item) return -rte_errno; - ret = iavf_fdir_parse_pattern(ad, pattern, error, filter); + ret = iavf_fdir_parse_pattern(ad, pattern, item->input_set_mask, + error, filter); if (ret) goto error; - input_set = filter->input_set; - if (!input_set || input_set & ~item->input_set_mask) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, - "Invalid input set"); - ret = -rte_errno; - goto error; - } - ret = iavf_fdir_parse_action(ad, actions, error, filter); if (ret) goto error;