X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Fi40e%2Fi40e_fdir.c;h=0b45bd90fb2fe84effe6190903ab885b01adaf91;hb=be6c228d4da377bd16a90f12fa0638a29059b4da;hp=e688b4f51ec6132eb6d29b59bb71fb6738154396;hpb=5c9222058df7cc10fa98c13d097f85a7fa0341a3;p=dpdk.git diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index e688b4f51e..0b45bd90fb 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,8 @@ (1 << RTE_ETH_FLOW_NONFRAG_IPV6_UDP) | \ (1 << RTE_ETH_FLOW_NONFRAG_IPV6_TCP) | \ (1 << RTE_ETH_FLOW_NONFRAG_IPV6_SCTP) | \ - (1 << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER)) + (1 << RTE_ETH_FLOW_NONFRAG_IPV6_OTHER) | \ + (1 << RTE_ETH_FLOW_L2_PAYLOAD)) #define I40E_FLEX_WORD_MASK(off) (0x80 >> (off)) @@ -366,7 +368,9 @@ i40e_init_flx_pld(struct i40e_pf *pf) /* initialize the masks */ for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP; - pctype <= I40E_FILTER_PCTYPE_FRAG_IPV6; pctype++) { + pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) { + if (!I40E_VALID_PCTYPE((enum i40e_filter_pctype)pctype)) + continue; pf->fdir.flex_mask[pctype].word_mask = 0; I40E_WRITE_REG(hw, I40E_PRTQF_FD_FLXINSET(pctype), 0); for (i = 0; i < I40E_FDIR_BITMASK_NUM_WORD; i++) { @@ -551,7 +555,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf, memset(flex_pit, 0, sizeof(flex_pit)); num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit); - for (i = 0; i < num; i++) { + for (i = 0; i < RTE_MIN(num, RTE_DIM(flex_pit)); i++) { field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i; /* record the info in fdir structure */ pf->fdir.flex_set[field_idx].src_offset = @@ -704,6 +708,9 @@ i40e_fdir_fill_eth_ip_head(const struct rte_eth_fdir_input *fdir_input, }; switch (fdir_input->flow_type) { + case RTE_ETH_FLOW_L2_PAYLOAD: + ether->ether_type = fdir_input->flow.l2_flow.ether_type; + break; case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: @@ -815,6 +822,13 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, sctp = (struct sctp_hdr *)(raw_pkt + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr)); payload = (unsigned char *)sctp + sizeof(struct sctp_hdr); + /* + * The source and destination fields in the transmitted packet + * need to be presented in a reversed order with respect + * to the expected received packets. + */ + sctp->src_port = fdir_input->flow.sctp4_flow.dst_port; + sctp->dst_port = fdir_input->flow.sctp4_flow.src_port; sctp->tag = fdir_input->flow.sctp4_flow.verify_tag; break; @@ -857,6 +871,13 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, sctp = (struct sctp_hdr *)(raw_pkt + sizeof(struct ether_hdr) + sizeof(struct ipv6_hdr)); payload = (unsigned char *)sctp + sizeof(struct sctp_hdr); + /* + * The source and destination fields in the transmitted packet + * need to be presented in a reversed order with respect + * to the expected received packets. + */ + sctp->src_port = fdir_input->flow.sctp6_flow.dst_port; + sctp->dst_port = fdir_input->flow.sctp6_flow.src_port; sctp->tag = fdir_input->flow.sctp6_flow.verify_tag; break; @@ -866,6 +887,17 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, sizeof(struct ipv6_hdr); set_idx = I40E_FLXPLD_L3_IDX; break; + case RTE_ETH_FLOW_L2_PAYLOAD: + payload = raw_pkt + sizeof(struct ether_hdr); + /* + * ARP packet is a special case on which the payload + * starts after the whole ARP header + */ + if (fdir_input->flow.l2_flow.ether_type == + rte_cpu_to_be_16(ETHER_TYPE_ARP)) + payload += sizeof(struct arp_hdr); + set_idx = I40E_FLXPLD_L2_IDX; + break; default: PMD_DRV_LOG(ERR, "unknown flow type %u.", fdir_input->flow_type); return -EINVAL; @@ -990,6 +1022,11 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "Invalid queue ID"); return -EINVAL; } + if (filter->input.flow_ext.is_vf && + filter->input.flow_ext.dst_id >= pf->vf_num) { + PMD_DRV_LOG(ERR, "Invalid VF ID"); + return -EINVAL; + } memset(pkt, 0, I40E_FDIR_PKT_LEN); @@ -1029,7 +1066,7 @@ i40e_fdir_filter_programming(struct i40e_pf *pf, volatile struct i40e_tx_desc *txdp; volatile struct i40e_filter_program_desc *fdirdp; uint32_t td_cmd; - uint16_t i; + uint16_t vsi_id, i; uint8_t dest; PMD_DRV_LOG(INFO, "filling filter programming descriptor."); @@ -1051,9 +1088,13 @@ i40e_fdir_filter_programming(struct i40e_pf *pf, I40E_TXD_FLTR_QW0_PCTYPE_SHIFT) & I40E_TXD_FLTR_QW0_PCTYPE_MASK); - /* Use LAN VSI Id by default */ + if (filter->input.flow_ext.is_vf) + vsi_id = pf->vfs[filter->input.flow_ext.dst_id].vsi->vsi_id; + else + /* Use LAN VSI Id by default */ + vsi_id = pf->main_vsi->vsi_id; fdirdp->qindex_flex_ptype_vsi |= - rte_cpu_to_le_32((pf->main_vsi->vsi_id << + rte_cpu_to_le_32((vsi_id << I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT) & I40E_TXD_FLTR_QW0_DEST_VSI_MASK); @@ -1110,7 +1151,8 @@ i40e_fdir_filter_programming(struct i40e_pf *pf, for (i = 0; i < I40E_FDIR_WAIT_COUNT; i++) { rte_delay_us(I40E_FDIR_WAIT_INTERVAL_US); - if (txdp->cmd_type_offset_bsz & + if ((txdp->cmd_type_offset_bsz & + rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) == rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE)) break; } @@ -1218,7 +1260,7 @@ i40e_fdir_info_get_flex_mask(struct i40e_pf *pf, uint16_t off_bytes, mask_tmp; for (i = I40E_FILTER_PCTYPE_NONF_IPV4_UDP; - i <= I40E_FILTER_PCTYPE_FRAG_IPV6; + i <= I40E_FILTER_PCTYPE_L2_PAYLOAD; i++) { mask = &pf->fdir.flex_mask[i]; if (!I40E_VALID_PCTYPE((enum i40e_filter_pctype)i)) @@ -1309,6 +1351,33 @@ i40e_fdir_stats_get(struct rte_eth_dev *dev, struct rte_eth_fdir_stats *stat) I40E_PFQF_FDSTAT_BEST_CNT_SHIFT); } +static int +i40e_fdir_filter_set(struct rte_eth_dev *dev, + struct rte_eth_hash_filter_info *info) +{ + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + int ret = 0; + + if (!info) { + PMD_DRV_LOG(ERR, "Invalid pointer"); + return -EFAULT; + } + + switch (info->info_type) { + case RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT: + ret = i40e_filter_inset_select(hw, + &(info->info.input_set_conf), RTE_ETH_FILTER_FDIR); + break; + default: + PMD_DRV_LOG(ERR, "FD filter info type (%d) not supported", + info->info_type); + return -EINVAL; + } + + return ret; +} + /* * i40e_fdir_ctrl_func - deal with all operations on flow director. * @pf: board private structure @@ -1349,6 +1418,10 @@ i40e_fdir_ctrl_func(struct rte_eth_dev *dev, case RTE_ETH_FILTER_INFO: i40e_fdir_info_get(dev, (struct rte_eth_fdir_info *)arg); break; + case RTE_ETH_FILTER_SET: + ret = i40e_fdir_filter_set(dev, + (struct rte_eth_hash_filter_info *)arg); + break; case RTE_ETH_FILTER_STATS: i40e_fdir_stats_get(dev, (struct rte_eth_fdir_stats *)arg); break;