Commit 849a742c authored by Kumar Sanghvi's avatar Kumar Sanghvi Committed by David S. Miller

cxgb4: Correct ntuple mask validation for hash filters

Earlier code of doing bitwise AND with field width bits was wrong.
Instead, simplify code to calculate ntuple_mask based on supplied
fields and then compare with mask configured in hw - which is the
correct and simpler way to validate ntuple mask.

Fixes: 3eb8b62d ("cxgb4: add support to create hash-filters via tc-flower offload")
Signed-off-by: default avatarKumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: default avatarGanesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d49baa7e
...@@ -836,7 +836,7 @@ bool is_filter_exact_match(struct adapter *adap, ...@@ -836,7 +836,7 @@ bool is_filter_exact_match(struct adapter *adap,
{ {
struct tp_params *tp = &adap->params.tp; struct tp_params *tp = &adap->params.tp;
u64 hash_filter_mask = tp->hash_filter_mask; u64 hash_filter_mask = tp->hash_filter_mask;
u32 mask; u64 ntuple_mask = 0;
if (!is_hashfilter(adap)) if (!is_hashfilter(adap))
return false; return false;
...@@ -865,73 +865,45 @@ bool is_filter_exact_match(struct adapter *adap, ...@@ -865,73 +865,45 @@ bool is_filter_exact_match(struct adapter *adap,
if (!fs->val.fport || fs->mask.fport != 0xffff) if (!fs->val.fport || fs->mask.fport != 0xffff)
return false; return false;
if (tp->fcoe_shift >= 0) { /* calculate tuple mask and compare with mask configured in hw */
mask = (hash_filter_mask >> tp->fcoe_shift) & FT_FCOE_W; if (tp->fcoe_shift >= 0)
if (mask && !fs->mask.fcoe) ntuple_mask |= (u64)fs->mask.fcoe << tp->fcoe_shift;
return false;
}
if (tp->port_shift >= 0) { if (tp->port_shift >= 0)
mask = (hash_filter_mask >> tp->port_shift) & FT_PORT_W; ntuple_mask |= (u64)fs->mask.iport << tp->port_shift;
if (mask && !fs->mask.iport)
return false;
}
if (tp->vnic_shift >= 0) { if (tp->vnic_shift >= 0) {
mask = (hash_filter_mask >> tp->vnic_shift) & FT_VNIC_ID_W; if ((adap->params.tp.ingress_config & VNIC_F))
ntuple_mask |= (u64)fs->mask.pfvf_vld << tp->vnic_shift;
if ((adap->params.tp.ingress_config & VNIC_F)) { else
if (mask && !fs->mask.pfvf_vld) ntuple_mask |= (u64)fs->mask.ovlan_vld <<
return false; tp->vnic_shift;
} else {
if (mask && !fs->mask.ovlan_vld)
return false;
}
} }
if (tp->vlan_shift >= 0) { if (tp->vlan_shift >= 0)
mask = (hash_filter_mask >> tp->vlan_shift) & FT_VLAN_W; ntuple_mask |= (u64)fs->mask.ivlan << tp->vlan_shift;
if (mask && !fs->mask.ivlan)
return false;
}
if (tp->tos_shift >= 0) { if (tp->tos_shift >= 0)
mask = (hash_filter_mask >> tp->tos_shift) & FT_TOS_W; ntuple_mask |= (u64)fs->mask.tos << tp->tos_shift;
if (mask && !fs->mask.tos)
return false;
}
if (tp->protocol_shift >= 0) { if (tp->protocol_shift >= 0)
mask = (hash_filter_mask >> tp->protocol_shift) & FT_PROTOCOL_W; ntuple_mask |= (u64)fs->mask.proto << tp->protocol_shift;
if (mask && !fs->mask.proto)
return false;
}
if (tp->ethertype_shift >= 0) { if (tp->ethertype_shift >= 0)
mask = (hash_filter_mask >> tp->ethertype_shift) & ntuple_mask |= (u64)fs->mask.ethtype << tp->ethertype_shift;
FT_ETHERTYPE_W;
if (mask && !fs->mask.ethtype)
return false;
}
if (tp->macmatch_shift >= 0) { if (tp->macmatch_shift >= 0)
mask = (hash_filter_mask >> tp->macmatch_shift) & FT_MACMATCH_W; ntuple_mask |= (u64)fs->mask.macidx << tp->macmatch_shift;
if (mask && !fs->mask.macidx)
return false;
}
if (tp->matchtype_shift >= 0) { if (tp->matchtype_shift >= 0)
mask = (hash_filter_mask >> tp->matchtype_shift) & ntuple_mask |= (u64)fs->mask.matchtype << tp->matchtype_shift;
FT_MPSHITTYPE_W;
if (mask && !fs->mask.matchtype) if (tp->frag_shift >= 0)
return false; ntuple_mask |= (u64)fs->mask.frag << tp->frag_shift;
}
if (tp->frag_shift >= 0) { if (ntuple_mask != hash_filter_mask)
mask = (hash_filter_mask >> tp->frag_shift) &
FT_FRAGMENTATION_W;
if (mask && !fs->mask.frag)
return false; return false;
}
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment