提交 eaefbd06 编写于 作者: J Jesse Brandeburg 提交者: Jeff Kirsher

i40e: refactor fdir setup function

This function did a lot of unnecessary cpu_to_xxx(foo) and making it
worse, each of these calls caused a lot of line wrapping.

Fix look and feel via a refactor of this function.  No functional
changes.
Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: NKavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 0976a016
...@@ -37,6 +37,7 @@ static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, ...@@ -37,6 +37,7 @@ static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
((u64)td_tag << I40E_TXD_QW1_L2TAG1_SHIFT)); ((u64)td_tag << I40E_TXD_QW1_L2TAG1_SHIFT));
} }
#define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
/** /**
* i40e_program_fdir_filter - Program a Flow Director filter * i40e_program_fdir_filter - Program a Flow Director filter
* @fdir_input: Packet data that will be filter parameters * @fdir_input: Packet data that will be filter parameters
...@@ -50,6 +51,7 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data, ...@@ -50,6 +51,7 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data,
struct i40e_tx_buffer *tx_buf; struct i40e_tx_buffer *tx_buf;
struct i40e_tx_desc *tx_desc; struct i40e_tx_desc *tx_desc;
struct i40e_ring *tx_ring; struct i40e_ring *tx_ring;
unsigned int fpt, dcc;
struct i40e_vsi *vsi; struct i40e_vsi *vsi;
struct device *dev; struct device *dev;
dma_addr_t dma; dma_addr_t dma;
...@@ -77,74 +79,61 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data, ...@@ -77,74 +79,61 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data,
fdir_desc = I40E_TX_FDIRDESC(tx_ring, i); fdir_desc = I40E_TX_FDIRDESC(tx_ring, i);
tx_buf = &tx_ring->tx_bi[i]; tx_buf = &tx_ring->tx_bi[i];
i++; tx_ring->next_to_use = (i + 1 < tx_ring->count) ? i + 1 : 0;
tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
fdir_desc->qindex_flex_ptype_vsi = cpu_to_le32((fdir_data->q_index fpt = (fdir_data->q_index << I40E_TXD_FLTR_QW0_QINDEX_SHIFT) &
<< I40E_TXD_FLTR_QW0_QINDEX_SHIFT) I40E_TXD_FLTR_QW0_QINDEX_MASK;
& I40E_TXD_FLTR_QW0_QINDEX_MASK);
fdir_desc->qindex_flex_ptype_vsi |= cpu_to_le32((fdir_data->flex_off fpt |= (fdir_data->flex_off << I40E_TXD_FLTR_QW0_FLEXOFF_SHIFT) &
<< I40E_TXD_FLTR_QW0_FLEXOFF_SHIFT) I40E_TXD_FLTR_QW0_FLEXOFF_MASK;
& I40E_TXD_FLTR_QW0_FLEXOFF_MASK);
fdir_desc->qindex_flex_ptype_vsi |= cpu_to_le32((fdir_data->pctype fpt |= (fdir_data->pctype << I40E_TXD_FLTR_QW0_PCTYPE_SHIFT) &
<< I40E_TXD_FLTR_QW0_PCTYPE_SHIFT) I40E_TXD_FLTR_QW0_PCTYPE_MASK;
& I40E_TXD_FLTR_QW0_PCTYPE_MASK);
/* Use LAN VSI Id if not programmed by user */ /* Use LAN VSI Id if not programmed by user */
if (fdir_data->dest_vsi == 0) if (fdir_data->dest_vsi == 0)
fdir_desc->qindex_flex_ptype_vsi |= fpt |= (pf->vsi[pf->lan_vsi]->id) <<
cpu_to_le32((pf->vsi[pf->lan_vsi]->id) I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT;
<< I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT);
else else
fdir_desc->qindex_flex_ptype_vsi |= fpt |= ((u32)fdir_data->dest_vsi <<
cpu_to_le32((((u32)fdir_data->dest_vsi) <<
I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT) & I40E_TXD_FLTR_QW0_DEST_VSI_SHIFT) &
I40E_TXD_FLTR_QW0_DEST_VSI_MASK); I40E_TXD_FLTR_QW0_DEST_VSI_MASK;
fdir_desc->dtype_cmd_cntindex = fdir_desc->qindex_flex_ptype_vsi = cpu_to_le32(fpt);
cpu_to_le32(I40E_TX_DESC_DTYPE_FILTER_PROG);
dcc = I40E_TX_DESC_DTYPE_FILTER_PROG;
if (add) if (add)
fdir_desc->dtype_cmd_cntindex |= cpu_to_le32( dcc |= I40E_FILTER_PROGRAM_DESC_PCMD_ADD_UPDATE <<
I40E_FILTER_PROGRAM_DESC_PCMD_ADD_UPDATE I40E_TXD_FLTR_QW1_PCMD_SHIFT;
<< I40E_TXD_FLTR_QW1_PCMD_SHIFT);
else else
fdir_desc->dtype_cmd_cntindex |= cpu_to_le32( dcc |= I40E_FILTER_PROGRAM_DESC_PCMD_REMOVE <<
I40E_FILTER_PROGRAM_DESC_PCMD_REMOVE I40E_TXD_FLTR_QW1_PCMD_SHIFT;
<< I40E_TXD_FLTR_QW1_PCMD_SHIFT);
fdir_desc->dtype_cmd_cntindex |= cpu_to_le32((fdir_data->dest_ctl dcc |= (fdir_data->dest_ctl << I40E_TXD_FLTR_QW1_DEST_SHIFT) &
<< I40E_TXD_FLTR_QW1_DEST_SHIFT) I40E_TXD_FLTR_QW1_DEST_MASK;
& I40E_TXD_FLTR_QW1_DEST_MASK);
fdir_desc->dtype_cmd_cntindex |= cpu_to_le32( dcc |= (fdir_data->fd_status << I40E_TXD_FLTR_QW1_FD_STATUS_SHIFT) &
(fdir_data->fd_status << I40E_TXD_FLTR_QW1_FD_STATUS_SHIFT) I40E_TXD_FLTR_QW1_FD_STATUS_MASK;
& I40E_TXD_FLTR_QW1_FD_STATUS_MASK);
if (fdir_data->cnt_index != 0) { if (fdir_data->cnt_index != 0) {
fdir_desc->dtype_cmd_cntindex |= dcc |= I40E_TXD_FLTR_QW1_CNT_ENA_MASK;
cpu_to_le32(I40E_TXD_FLTR_QW1_CNT_ENA_MASK); dcc |= ((u32)fdir_data->cnt_index <<
fdir_desc->dtype_cmd_cntindex |=
cpu_to_le32((((u32)fdir_data->cnt_index) <<
I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) & I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) &
I40E_TXD_FLTR_QW1_CNTINDEX_MASK); I40E_TXD_FLTR_QW1_CNTINDEX_MASK;
} }
fdir_desc->dtype_cmd_cntindex = cpu_to_le32(dcc);
fdir_desc->fd_id = cpu_to_le32(fdir_data->fd_id); fdir_desc->fd_id = cpu_to_le32(fdir_data->fd_id);
/* Now program a dummy descriptor */ /* Now program a dummy descriptor */
i = tx_ring->next_to_use; i = tx_ring->next_to_use;
tx_desc = I40E_TX_DESC(tx_ring, i); tx_desc = I40E_TX_DESC(tx_ring, i);
i++; tx_ring->next_to_use = (i + 1 < tx_ring->count) ? i + 1 : 0;
tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
tx_desc->buffer_addr = cpu_to_le64(dma); tx_desc->buffer_addr = cpu_to_le64(dma);
td_cmd = I40E_TX_DESC_CMD_EOP | td_cmd = I40E_TXD_CMD | I40E_TX_DESC_CMD_DUMMY;
I40E_TX_DESC_CMD_RS |
I40E_TX_DESC_CMD_DUMMY;
tx_desc->cmd_type_offset_bsz = tx_desc->cmd_type_offset_bsz =
build_ctob(td_cmd, 0, I40E_FDIR_MAX_RAW_PACKET_LOOKUP, 0); build_ctob(td_cmd, 0, I40E_FDIR_MAX_RAW_PACKET_LOOKUP, 0);
...@@ -1254,7 +1243,6 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, ...@@ -1254,7 +1243,6 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
fdir_desc->dtype_cmd_cntindex = cpu_to_le32(dtype_cmd); fdir_desc->dtype_cmd_cntindex = cpu_to_le32(dtype_cmd);
} }
#define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
/** /**
* i40e_tx_prepare_vlan_flags - prepare generic TX VLAN tagging flags for HW * i40e_tx_prepare_vlan_flags - prepare generic TX VLAN tagging flags for HW
* @skb: send buffer * @skb: send buffer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册