qed: Add support of HW filter block

This patch introduces the functionality of HW filter block.
It adds and removes filters based on source and target TCP port.

It also add functionality to clear all filters at once.

Acked-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: Omkar Kulkarni <okulkarni@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: Michal Kalderon <mkalderon@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Prabhakar Kushwaha 2021-06-02 20:16:52 +03:00 committed by David S. Miller
parent 76684ab8f4
commit 203d136e89
4 changed files with 127 additions and 0 deletions

View File

@ -49,6 +49,8 @@ extern const struct qed_common_ops qed_common_ops_pass;
#define QED_MIN_WIDS (4)
#define QED_PF_DEMS_SIZE (4)
#define QED_LLH_DONT_CARE 0
/* cau states */
enum qed_coalescing_mode {
QED_COAL_MODE_DISABLE,
@ -1005,4 +1007,10 @@ int qed_mfw_fill_tlv_data(struct qed_hwfn *hwfn,
void qed_hw_info_set_offload_tc(struct qed_hw_info *p_info, u8 tc);
void qed_periodic_db_rec_start(struct qed_hwfn *p_hwfn);
int qed_llh_add_src_tcp_port_filter(struct qed_dev *cdev, u16 src_port);
int qed_llh_add_dst_tcp_port_filter(struct qed_dev *cdev, u16 dest_port);
void qed_llh_remove_src_tcp_port_filter(struct qed_dev *cdev, u16 src_port);
void qed_llh_remove_dst_tcp_port_filter(struct qed_dev *cdev, u16 src_port);
void qed_llh_clear_all_filters(struct qed_dev *cdev);
#endif /* _QED_H */

View File

@ -5362,3 +5362,93 @@ void qed_set_fw_mac_addr(__le16 *fw_msb,
((u8 *)fw_lsb)[0] = mac[5];
((u8 *)fw_lsb)[1] = mac[4];
}
static int qed_llh_shadow_remove_all_filters(struct qed_dev *cdev, u8 ppfid)
{
struct qed_llh_info *p_llh_info = cdev->p_llh_info;
struct qed_llh_filter_info *p_filters;
int rc;
rc = qed_llh_shadow_sanity(cdev, ppfid, 0, "remove_all");
if (rc)
return rc;
p_filters = p_llh_info->pp_filters[ppfid];
memset(p_filters, 0, NIG_REG_LLH_FUNC_FILTER_EN_SIZE *
sizeof(*p_filters));
return 0;
}
static void qed_llh_clear_ppfid_filters(struct qed_dev *cdev, u8 ppfid)
{
struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev);
struct qed_ptt *p_ptt = qed_ptt_acquire(p_hwfn);
u8 filter_idx, abs_ppfid;
int rc = 0;
if (!p_ptt)
return;
if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits) &&
!test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits))
goto out;
rc = qed_llh_abs_ppfid(cdev, ppfid, &abs_ppfid);
if (rc)
goto out;
rc = qed_llh_shadow_remove_all_filters(cdev, ppfid);
if (rc)
goto out;
for (filter_idx = 0; filter_idx < NIG_REG_LLH_FUNC_FILTER_EN_SIZE;
filter_idx++) {
rc = qed_llh_remove_filter(p_hwfn, p_ptt,
abs_ppfid, filter_idx);
if (rc)
goto out;
}
out:
qed_ptt_release(p_hwfn, p_ptt);
}
int qed_llh_add_src_tcp_port_filter(struct qed_dev *cdev, u16 src_port)
{
return qed_llh_add_protocol_filter(cdev, 0,
QED_LLH_FILTER_TCP_SRC_PORT,
src_port, QED_LLH_DONT_CARE);
}
void qed_llh_remove_src_tcp_port_filter(struct qed_dev *cdev, u16 src_port)
{
qed_llh_remove_protocol_filter(cdev, 0,
QED_LLH_FILTER_TCP_SRC_PORT,
src_port, QED_LLH_DONT_CARE);
}
int qed_llh_add_dst_tcp_port_filter(struct qed_dev *cdev, u16 dest_port)
{
return qed_llh_add_protocol_filter(cdev, 0,
QED_LLH_FILTER_TCP_DEST_PORT,
QED_LLH_DONT_CARE, dest_port);
}
void qed_llh_remove_dst_tcp_port_filter(struct qed_dev *cdev, u16 dest_port)
{
qed_llh_remove_protocol_filter(cdev, 0,
QED_LLH_FILTER_TCP_DEST_PORT,
QED_LLH_DONT_CARE, dest_port);
}
void qed_llh_clear_all_filters(struct qed_dev *cdev)
{
u8 ppfid;
if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits) &&
!test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits))
return;
for (ppfid = 0; ppfid < cdev->p_llh_info->num_ppfid; ppfid++)
qed_llh_clear_ppfid_filters(cdev, ppfid);
}

View File

@ -805,6 +805,11 @@ static const struct qed_nvmetcp_ops qed_nvmetcp_ops_pass = {
.update_conn = &qed_nvmetcp_update_conn,
.destroy_conn = &qed_nvmetcp_destroy_conn,
.clear_sq = &qed_nvmetcp_clear_conn_sq,
.add_src_tcp_port_filter = &qed_llh_add_src_tcp_port_filter,
.remove_src_tcp_port_filter = &qed_llh_remove_src_tcp_port_filter,
.add_dst_tcp_port_filter = &qed_llh_add_dst_tcp_port_filter,
.remove_dst_tcp_port_filter = &qed_llh_remove_dst_tcp_port_filter,
.clear_all_filters = &qed_llh_clear_all_filters
};
const struct qed_nvmetcp_ops *qed_get_nvmetcp_ops(void)

View File

@ -123,6 +123,20 @@ struct qed_nvmetcp_cb_ops {
* @param cdev
* @param handle - the connection handle.
* @return 0 on success, otherwise error value.
* @add_src_tcp_port_filter: Add source tcp port filter
* @param cdev
* @param src_port
* @remove_src_tcp_port_filter: Remove source tcp port filter
* @param cdev
* @param src_port
* @add_dst_tcp_port_filter: Add destination tcp port filter
* @param cdev
* @param dest_port
* @remove_dst_tcp_port_filter: Remove destination tcp port filter
* @param cdev
* @param dest_port
* @clear_all_filters: Clear all filters.
* @param cdev
*/
struct qed_nvmetcp_ops {
const struct qed_common_ops *common;
@ -158,6 +172,16 @@ struct qed_nvmetcp_ops {
int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
int (*clear_sq)(struct qed_dev *cdev, u32 handle);
int (*add_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
void (*remove_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
int (*add_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
void (*remove_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
void (*clear_all_filters)(struct qed_dev *cdev);
};
const struct qed_nvmetcp_ops *qed_get_nvmetcp_ops(void);