[dpdk-dev] [PATCH 17/49] net/ice/base: use macro instead of magic 8
Leyi Rong
leyi.rong at intel.com
Tue Jun 4 07:42:16 CEST 2019
Replace the use of the magic number 8 by BITS_PER_BYTE when calculating
the number of bits from the number of bytes.
Signed-off-by: Bruce Allan <bruce.w.allan at intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr at intel.com>
Signed-off-by: Leyi Rong <leyi.rong at intel.com>
---
drivers/net/ice/base/ice_flex_pipe.c | 4 +-
drivers/net/ice/base/ice_flow.c | 74 +++++++++++++++-------------
2 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 5faee6d52..b569b91a7 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -3862,7 +3862,7 @@ ice_update_fd_swap(struct ice_hw *hw, u16 prof_id, struct ice_fv_word *es)
idx = (j * 4) + k;
if (used[idx])
- raw_entry |= used[idx] << (k * 8);
+ raw_entry |= used[idx] << (k * BITS_PER_BYTE);
}
/* write the appropriate register set, based on HW block */
@@ -3955,7 +3955,7 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],
u16 ptype;
u8 m;
- ptype = byte * 8 + bit;
+ ptype = byte * BITS_PER_BYTE + bit;
if (ptype < ICE_FLOW_PTYPE_MAX) {
prof->ptype[prof->ptype_count] = ptype;
diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c
index dccd7d3c7..9f2a794bc 100644
--- a/drivers/net/ice/base/ice_flow.c
+++ b/drivers/net/ice/base/ice_flow.c
@@ -26,8 +26,8 @@
* protocol headers. Displacement values are expressed in number of bits.
*/
#define ICE_FLOW_FLD_IPV6_TTL_DSCP_DISP (-4)
-#define ICE_FLOW_FLD_IPV6_TTL_PROT_DISP ((-2) * 8)
-#define ICE_FLOW_FLD_IPV6_TTL_TTL_DISP ((-1) * 8)
+#define ICE_FLOW_FLD_IPV6_TTL_PROT_DISP ((-2) * BITS_PER_BYTE)
+#define ICE_FLOW_FLD_IPV6_TTL_TTL_DISP ((-1) * BITS_PER_BYTE)
/* Describe properties of a protocol header field */
struct ice_flow_field_info {
@@ -36,70 +36,76 @@ struct ice_flow_field_info {
u16 size; /* Size of fields in bits */
};
+#define ICE_FLOW_FLD_INFO(_hdr, _offset_bytes, _size_bytes) { \
+ .hdr = _hdr, \
+ .off = _offset_bytes * BITS_PER_BYTE, \
+ .size = _size_bytes * BITS_PER_BYTE, \
+}
+
/* Table containing properties of supported protocol header fields */
static const
struct ice_flow_field_info ice_flds_info[ICE_FLOW_FIELD_IDX_MAX] = {
/* Ether */
/* ICE_FLOW_FIELD_IDX_ETH_DA */
- { ICE_FLOW_SEG_HDR_ETH, 0, ETH_ALEN * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ETH, 0, ETH_ALEN),
/* ICE_FLOW_FIELD_IDX_ETH_SA */
- { ICE_FLOW_SEG_HDR_ETH, ETH_ALEN * 8, ETH_ALEN * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ETH, ETH_ALEN, ETH_ALEN),
/* ICE_FLOW_FIELD_IDX_S_VLAN */
- { ICE_FLOW_SEG_HDR_VLAN, 12 * 8, ICE_FLOW_FLD_SZ_VLAN * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_VLAN, 12, ICE_FLOW_FLD_SZ_VLAN),
/* ICE_FLOW_FIELD_IDX_C_VLAN */
- { ICE_FLOW_SEG_HDR_VLAN, 14 * 8, ICE_FLOW_FLD_SZ_VLAN * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_VLAN, 14, ICE_FLOW_FLD_SZ_VLAN),
/* ICE_FLOW_FIELD_IDX_ETH_TYPE */
- { ICE_FLOW_SEG_HDR_ETH, 12 * 8, ICE_FLOW_FLD_SZ_ETH_TY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* 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ICMP, 0, ICE_FLOW_FLD_SZ_ICMP_TYPE),
/* ICE_FLOW_FIELD_IDX_ICMP_CODE */
- { ICE_FLOW_SEG_HDR_ICMP, 1 * 8, ICE_FLOW_FLD_SZ_ICMP_CODE * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_ICMP, 1, ICE_FLOW_FLD_SZ_ICMP_CODE),
/* GRE */
/* ICE_FLOW_FIELD_IDX_GRE_KEYID */
- { ICE_FLOW_SEG_HDR_GRE, 12 * 8, ICE_FLOW_FLD_SZ_GRE_KEYID * 8 },
+ ICE_FLOW_FLD_INFO(ICE_FLOW_SEG_HDR_GRE, 12, ICE_FLOW_FLD_SZ_GRE_KEYID),
};
/* Bitmaps indicating relevant packet types for a particular protocol header
@@ -644,7 +650,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
/* Each extraction sequence entry is a word in size, and extracts a
* word-aligned offset from a protocol header.
*/
- ese_bits = ICE_FLOW_FV_EXTRACT_SZ * 8;
+ ese_bits = ICE_FLOW_FV_EXTRACT_SZ * BITS_PER_BYTE;
flds[fld].xtrct.prot_id = prot_id;
flds[fld].xtrct.off = (ice_flds_info[fld].off / ese_bits) *
@@ -737,15 +743,17 @@ ice_flow_xtract_raws(struct ice_hw *hw, struct ice_flow_prof_params *params,
raw->info.xtrct.prot_id = ICE_PROT_PAY;
raw->info.xtrct.off = (off / ICE_FLOW_FV_EXTRACT_SZ) *
ICE_FLOW_FV_EXTRACT_SZ;
- raw->info.xtrct.disp = (off % ICE_FLOW_FV_EXTRACT_SZ) * 8;
+ raw->info.xtrct.disp = (off % ICE_FLOW_FV_EXTRACT_SZ) *
+ BITS_PER_BYTE;
raw->info.xtrct.idx = params->es_cnt;
/* Determine the number of field vector entries this raw field
* consumes.
*/
cnt = DIVIDE_AND_ROUND_UP(raw->info.xtrct.disp +
- (raw->info.src.last * 8),
- ICE_FLOW_FV_EXTRACT_SZ * 8);
+ (raw->info.src.last * BITS_PER_BYTE),
+ (ICE_FLOW_FV_EXTRACT_SZ *
+ BITS_PER_BYTE));
off = raw->info.xtrct.off;
for (j = 0; j < cnt; j++) {
/* Make sure the number of extraction sequence required
--
2.17.1
More information about the dev
mailing list