Skip to content

Commit 3893fc6

Browse files
Manish Chopradavem330
authored andcommitted
qed*: Support other classification modes.
Currently, driver supports flow classification to PF receive queues based on TCP/UDP 4 tuples [src_ip, dst_ip, src_port, dst_port] only. This patch enables to configure different flow profiles [For example - only UDP dest port or src_ip based] on the adapter so that classification can be done according to just those fields as well. Although, at a time just one type of flow configuration is supported due to limited number of flow profiles available on the device. For example - ethtool -N enp7s0f0 flow-type udp4 dst-port 45762 action 2 ethtool -N enp7s0f0 flow-type tcp4 src-ip 192.16.4.10 action 1 ethtool -N enp7s0f0 flow-type udp6 dst-port 45762 action 3 Signed-off-by: Manish Chopra <manish.chopra@cavium.com> Signed-off-by: Shahed Shaikh <shahed.shaikh@cavium.com> Signed-off-by: Ariel Elior <ariel.elior@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 89ffd14 commit 3893fc6

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎drivers/net/ethernet/qlogic/qed/qed_l2.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,8 @@ qed_arfs_mode_to_hsi(enum qed_filter_config_mode mode)
19731973
return GFT_PROFILE_TYPE_4_TUPLE;
19741974
if (mode == QED_FILTER_CONFIG_MODE_IP_DEST)
19751975
return GFT_PROFILE_TYPE_IP_DST_ADDR;
1976+
if (mode == QED_FILTER_CONFIG_MODE_IP_SRC)
1977+
return GFT_PROFILE_TYPE_IP_SRC_ADDR;
19761978
return GFT_PROFILE_TYPE_L4_DST_PORT;
19771979
}
19781980

‎drivers/net/ethernet/qlogic/qede/qede_filter.c‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,17 @@ static int qede_flow_spec_to_tuple_ipv4_common(struct qede_dev *edev,
16231623
t->src_port = fs->h_u.tcp_ip4_spec.psrc;
16241624
t->dst_port = fs->h_u.tcp_ip4_spec.pdst;
16251625

1626-
/* We must have a valid 4-tuple */
1626+
/* We must either have a valid 4-tuple or only dst port
1627+
* or only src ip as an input
1628+
*/
16271629
if (t->src_port && t->dst_port && t->src_ipv4 && t->dst_ipv4) {
16281630
t->mode = QED_FILTER_CONFIG_MODE_5_TUPLE;
1631+
} else if (!t->src_port && t->dst_port &&
1632+
!t->src_ipv4 && !t->dst_ipv4) {
1633+
t->mode = QED_FILTER_CONFIG_MODE_L4_PORT;
1634+
} else if (!t->src_port && !t->dst_port &&
1635+
!t->dst_ipv4 && t->src_ipv4) {
1636+
t->mode = QED_FILTER_CONFIG_MODE_IP_SRC;
16291637
} else {
16301638
DP_INFO(edev, "Invalid N-tuple\n");
16311639
return -EOPNOTSUPP;
@@ -1697,11 +1705,21 @@ static int qede_flow_spec_to_tuple_ipv6_common(struct qede_dev *edev,
16971705
t->src_port = fs->h_u.tcp_ip6_spec.psrc;
16981706
t->dst_port = fs->h_u.tcp_ip6_spec.pdst;
16991707

1700-
/* We must make sure we have a valid 4-tuple */
1708+
/* We must make sure we have a valid 4-tuple or only dest port
1709+
* or only src ip as an input
1710+
*/
17011711
if (t->src_port && t->dst_port &&
17021712
memcmp(&t->src_ipv6, p, sizeof(struct in6_addr)) &&
17031713
memcmp(&t->dst_ipv6, p, sizeof(struct in6_addr))) {
17041714
t->mode = QED_FILTER_CONFIG_MODE_5_TUPLE;
1715+
} else if (!t->src_port && t->dst_port &&
1716+
!memcmp(&t->src_ipv6, p, sizeof(struct in6_addr)) &&
1717+
!memcmp(&t->dst_ipv6, p, sizeof(struct in6_addr))) {
1718+
t->mode = QED_FILTER_CONFIG_MODE_L4_PORT;
1719+
} else if (!t->src_port && !t->dst_port &&
1720+
!memcmp(&t->dst_ipv6, p, sizeof(struct in6_addr)) &&
1721+
memcmp(&t->src_ipv6, p, sizeof(struct in6_addr))) {
1722+
t->mode = QED_FILTER_CONFIG_MODE_IP_SRC;
17051723
} else {
17061724
DP_INFO(edev, "Invalid N-tuple\n");
17071725
return -EOPNOTSUPP;
@@ -1779,6 +1797,15 @@ static int qede_flow_spec_validate(struct qede_dev *edev,
17791797
return -EINVAL;
17801798
}
17811799

1800+
/* Check if the filtering-mode could support the filter */
1801+
if (edev->arfs->filter_count &&
1802+
edev->arfs->mode != t->mode) {
1803+
DP_INFO(edev,
1804+
"flow_spec would require filtering mode %08x, but %08x is configured\n",
1805+
t->mode, edev->arfs->filter_count);
1806+
return -EINVAL;
1807+
}
1808+
17821809
if (fs->ring_cookie >= QEDE_RSS_COUNT(edev)) {
17831810
DP_INFO(edev, "Queue out-of-bounds\n");
17841811
return -EINVAL;

‎include/linux/qed/qed_eth_if.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ enum qed_filter_config_mode {
6666
QED_FILTER_CONFIG_MODE_5_TUPLE,
6767
QED_FILTER_CONFIG_MODE_L4_PORT,
6868
QED_FILTER_CONFIG_MODE_IP_DEST,
69+
QED_FILTER_CONFIG_MODE_IP_SRC,
6970
};
7071

7172
struct qed_ntuple_filter_params {

0 commit comments

Comments
 (0)