From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=12.32.117.8 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129164; b=TWYB2/vcS1ZHtxiULZDmZdfd5gto3i+Z4+lng7sWpzDzyBDfO12BjbCfiRYzNyWUAjqH 4w3tik7pUGPDLTG451mMQU3wJ/uhQLHbZZhcIccJ98owInF7viGFdWaHL2d6nZp2koXMo xqakNkPapYcDcdBo6l7J/HJVIg0rxM0vBiZgyQS2lgsLH1+Ti3zoh3JYKsGD0msn1Jw32 io28U9GMUzWNhgUe3s0Ch+UB13QlgeDeW9DJaL7Ilfmq3AxOrVmBJ4Ol/doLRp1/dPVAN Av1j5ANtru+nd5hZwEdbt/6kDQjYqaWhfYC3rq4GcC8D0w92Tbk8AyQvwMjvRMYxvQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129164; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=F96fICapvxRG4akSXVM1/wJFss/rrBO+xKBkMJecDGg=; b=WyyqhlAeCFq2/g4uzboBcNuLBqSpobaaZs/ixRyFCHcQPfPqcnnXoC+5l5+qF3KfBkNH IBt71WZ6qvaoLI3cQjVzyajvy7cEeFDjQlrCb5sQs6GQp2wQ0FAaQ4KIiVJ1lYN9L/L0m Yp43XCmoUhZa4EaazY/jUvlI6RaFi/ODJ6s/xnmULNoGYVE3R2YaVc1NkZZE3QLi3KkZc E4jame0dBwH/T8HrhUSEoyeJcyyYdEsvFQj9kWMvCBHbxneIC3lQsEbQrZrbNJ/mC7EXn UbZDiBgh8rjkjynJEVoabE8utEFen5k8hUV4iRZ7Ae4s9VLBG7YsvYoheYpm9wcYWVQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chelsio.com; spf=pass smtp.mailfrom=chelsio.com; arc=none smtp.remote-ip=12.32.117.8 Received: from stargate.chelsio.com (unknown [12.32.117.8]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5404460A2628 for ; Tue, 1 Dec 2026 12:45:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5404460A2628 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=chelsio.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chelsio.com Received: from mehrangarh-blr-asicdesigners-com.asicdesigners.com (mehrangarh.blr.asicdesigners.com [10.193.185.169]) by stargate.chelsio.com (8.14.7/8.14.7) with ESMTP id 6B1Ci7oW026690; Tue, 1 Dec 2026 04:45:32 -0800 From: Potnuri Bharat Teja To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, bharat@chelsio.com, harshitha.vr@chelsio.com Subject: [PATCH net-next v6 08/12] cxgb4: Add T7 support to the filter infrastructure Date: Tue, 1 Dec 2026 17:15:52 -0500 Message-Id: <20261201221556.251018-9-bharat@chelsio.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20261201221556.251018-1-bharat@chelsio.com> References: <20261201221556.251018-1-bharat@chelsio.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit T7 changes a number of filter related register fields, firmware work request formats and CPL definitions. Update the filter code to use the T7 encodings while preserving the existing behaviour on earlier adapters. - Use the T7 reply channel and queue number encodings in the CPL_SET_TCB_FIELD requests sent for filters. - Validate filter specifications against the T7 TP filter field bits, which moved by one position in TP_VLAN_PRI_MAP. - Build hash filter CPL_ACT_OPEN_REQ/CPL_ACT_OPEN_REQ6 requests with the T7 CPL layout and T7 filter tuple encoding. On T7 the Tx and Rx channel are a single channel carried in opt0, so the legacy opt2 RX_CHANNEL field is left 0. The requests are zeroed before they are filled in. - Treat CLIP handling for IPv6 filters and the hash filter configuration checks as T6 and later rather than T6 only. - cxgb4_create_server_filter() decides whether to match on the ingress port and protocol from the per chip tuple shifts computed in t4_init_tp_params() instead of the T4-T6 TP_VLAN_PRI_MAP bits. Signed-off-by: Potnuri Bharat Teja --- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 221 ++++++++++++------ .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 +- 2 files changed, 155 insertions(+), 74 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c index 657d96b9e2f6..839cd1ffde10 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c @@ -66,9 +66,14 @@ static int set_tcb_field(struct adapter *adap, struct filter_entry *f, req = (struct cpl_set_tcb_field *)__skb_put_zero(skb, sizeof(*req)); INIT_TP_WR_CPL(req, CPL_SET_TCB_FIELD, ftid); - req->reply_ctrl = htons(REPLY_CHAN_V(0) | - QUEUENO_V(adap->sge.fw_evtq.abs_id) | - NO_REPLY_V(no_reply)); + if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T7) + req->reply_ctrl = htons(T7_REPLY_CHAN_V(0) | + T7_QUEUENO_V(adap->sge.fw_evtq.abs_id) | + NO_REPLY_V(no_reply)); + else + req->reply_ctrl = htons(REPLY_CHAN_V(0) | + QUEUENO_V(adap->sge.fw_evtq.abs_id) | + NO_REPLY_V(no_reply)); req->word_cookie = htons(TCB_WORD_V(word) | TCB_COOKIE_V(ftid)); req->mask = cpu_to_be64(mask); req->val = cpu_to_be64(val); @@ -249,32 +254,53 @@ static int validate_filter(struct net_device *dev, struct ch_filter_specification *fs) { struct adapter *adapter = netdev2adap(dev); - u32 fconf, iconf; + u32 fconf, iconf, chip_ver; + chip_ver = CHELSIO_CHIP_VERSION(adapter->params.chip); /* Check for unconfigured fields being used. */ iconf = adapter->params.tp.ingress_config; fconf = fs->hash ? adapter->params.tp.filter_mask : adapter->params.tp.vlan_pri_map; - if (unsupported(fconf, FCOE_F, fs->val.fcoe, fs->mask.fcoe) || - unsupported(fconf, PORT_F, fs->val.iport, fs->mask.iport) || - unsupported(fconf, TOS_F, fs->val.tos, fs->mask.tos) || - unsupported(fconf, ETHERTYPE_F, fs->val.ethtype, - fs->mask.ethtype) || - unsupported(fconf, MACMATCH_F, fs->val.macidx, fs->mask.macidx) || - unsupported(fconf, MPSHITTYPE_F, fs->val.matchtype, - fs->mask.matchtype) || - unsupported(fconf, FRAGMENTATION_F, fs->val.frag, fs->mask.frag) || - unsupported(fconf, PROTOCOL_F, fs->val.proto, fs->mask.proto) || - unsupported(fconf, VNIC_ID_F, fs->val.pfvf_vld, - fs->mask.pfvf_vld) || - unsupported(fconf, VNIC_ID_F, fs->val.ovlan_vld, - fs->mask.ovlan_vld) || - unsupported(fconf, VNIC_ID_F, fs->val.encap_vld, - fs->mask.encap_vld) || - unsupported(fconf, VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld)) - return -EOPNOTSUPP; - + if (chip_ver >= CHELSIO_T7) { + if (unsupported(fconf, T7_FCOE_F, fs->val.fcoe, fs->mask.fcoe) || + unsupported(fconf, T7_PORT_F, fs->val.iport, fs->mask.iport) || + unsupported(fconf, T7_TOS_F, fs->val.tos, fs->mask.tos) || + unsupported(fconf, T7_ETHERTYPE_F, fs->val.ethtype, + fs->mask.ethtype) || + unsupported(fconf, T7_MACMATCH_F, fs->val.macidx, fs->mask.macidx) || + unsupported(fconf, T7_MPSHITTYPE_F, fs->val.matchtype, + fs->mask.matchtype) || + unsupported(fconf, T7_FRAGMENTATION_F, fs->val.frag, fs->mask.frag) || + unsupported(fconf, T7_PROTOCOL_F, fs->val.proto, fs->mask.proto) || + unsupported(fconf, T7_VNIC_ID_F, fs->val.pfvf_vld, + fs->mask.pfvf_vld) || + unsupported(fconf, T7_VNIC_ID_F, fs->val.ovlan_vld, + fs->mask.ovlan_vld) || + unsupported(fconf, T7_VNIC_ID_F, fs->val.encap_vld, + fs->mask.encap_vld) || + unsupported(fconf, T7_VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld)) + return -EOPNOTSUPP; + } else { + if (unsupported(fconf, FCOE_F, fs->val.fcoe, fs->mask.fcoe) || + unsupported(fconf, PORT_F, fs->val.iport, fs->mask.iport) || + unsupported(fconf, TOS_F, fs->val.tos, fs->mask.tos) || + unsupported(fconf, ETHERTYPE_F, fs->val.ethtype, + fs->mask.ethtype) || + unsupported(fconf, MACMATCH_F, fs->val.macidx, fs->mask.macidx) || + unsupported(fconf, MPSHITTYPE_F, fs->val.matchtype, + fs->mask.matchtype) || + unsupported(fconf, FRAGMENTATION_F, fs->val.frag, fs->mask.frag) || + unsupported(fconf, PROTOCOL_F, fs->val.proto, fs->mask.proto) || + unsupported(fconf, VNIC_ID_F, fs->val.pfvf_vld, + fs->mask.pfvf_vld) || + unsupported(fconf, VNIC_ID_F, fs->val.ovlan_vld, + fs->mask.ovlan_vld) || + unsupported(fconf, VNIC_ID_F, fs->val.encap_vld, + fs->mask.encap_vld) || + unsupported(fconf, VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld)) + return -EOPNOTSUPP; + } /* T4 inconveniently uses the same FT_VNIC_ID_W bits for both the Outer * VLAN Tag and PF/VF/VFvld fields based on VNIC_F being set * in TP_INGRESS_CONFIG. Hense the somewhat crazy checks @@ -993,7 +1019,9 @@ void clear_filter(struct adapter *adap, struct filter_entry *f) t4_free_encap_mac_filt(adap, pi->viid, f->fs.val.ovlan & 0x1ff, 0); - if ((f->fs.hash || is_t6(adap->params.chip)) && f->fs.type) + if ((f->fs.hash || + (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T6)) && + f->fs.type) cxgb4_clip_release(f->dev, (const u32 *)&f->fs.val.lip, 1); /* The zeroing of the filter rule below clears the filter valid, @@ -1292,24 +1320,33 @@ static u64 hash_filter_ntuple(struct ch_filter_specification *fs, return ntuple; } +/* RX channel for the CPL_ACT_OPEN_REQ opt2 RX_CHANNEL field. On T7 the + * Tx and Rx channel are a single "Channel" carried in opt0, and the 1 bit + * legacy RX_CHANNEL field is deprecated and must be 0. T7 has up to 4 + * channels, which would also overflow into CCTRL_ECN. + */ +static u32 cxgb4_hash_filter_rx_chan(struct adapter *adap, struct filter_entry *f) +{ + if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T7) + return 0; + + return cxgb4_port_e2cchan(f->dev); +} + static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb, unsigned int qid_filterid, struct adapter *adap) { struct cpl_t6_act_open_req6 *t6req = NULL; + struct cpl_t7_act_open_req6 *t7req = NULL; struct cpl_act_open_req6 *req = NULL; + u32 chip_ver; + __be32 opt2; + __be64 opt0; - t6req = (struct cpl_t6_act_open_req6 *)__skb_put(skb, sizeof(*t6req)); - INIT_TP_WR(t6req, 0); - req = (struct cpl_act_open_req6 *)t6req; - OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6, qid_filterid)); - req->local_port = cpu_to_be16(f->fs.val.lport); - req->peer_port = cpu_to_be16(f->fs.val.fport); - req->local_ip_hi = *(__be64 *)(&f->fs.val.lip); - req->local_ip_lo = *(((__be64 *)&f->fs.val.lip) + 1); - req->peer_ip_hi = *(__be64 *)(&f->fs.val.fip); - req->peer_ip_lo = *(((__be64 *)&f->fs.val.fip) + 1); - req->opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE || - f->fs.newvlan == VLAN_REWRITE) | + chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip); + + opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE || + f->fs.newvlan == VLAN_REWRITE) | DELACK_V(f->fs.hitcnts) | L2T_IDX_V(f->l2t ? f->l2t->idx : 0) | SMAC_SEL_V((cxgb4_port_viid(f->dev) & @@ -1319,52 +1356,90 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb, ULP_MODE_V(f->fs.nat_mode ? ULP_MODE_TCPDDP : ULP_MODE_NONE) | TCAM_BYPASS_F | NON_OFFLOAD_F); - t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, - f->dev))); - t6req->opt2 = htonl(RSS_QUEUE_VALID_F | - RSS_QUEUE_V(f->fs.iq) | - TX_QUEUE_V(f->fs.nat_mode) | - T5_OPT_2_VALID_F | - RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) | - PACE_V((f->fs.maskhash) | + opt2 = cpu_to_be32(RSS_QUEUE_VALID_F | + RSS_QUEUE_V(f->fs.iq) | + TX_QUEUE_V(f->fs.nat_mode) | + T5_OPT_2_VALID_F | + RX_CHANNEL_V(cxgb4_hash_filter_rx_chan(adap, f)) | + PACE_V((f->fs.maskhash) | ((f->fs.dirsteerhash) << 1))); + + if (chip_ver >= CHELSIO_T7) { + t7req = (struct cpl_t7_act_open_req6 *)__skb_put_zero(skb, sizeof(*t7req)); + INIT_TP_WR(t7req, 0); + req = (struct cpl_act_open_req6 *)t7req; + t7req->opt0 = opt0; + t7req->opt2 = opt2; + t7req->params = cpu_to_be64(T7_FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev))); + } else { + t6req = (struct cpl_t6_act_open_req6 *)__skb_put_zero(skb, sizeof(*t6req)); + INIT_TP_WR(t6req, 0); + req = (struct cpl_act_open_req6 *)t6req; + t6req->opt0 = opt0; + t6req->opt2 = opt2; + t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev))); + } + + OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6, qid_filterid)); + req->local_port = cpu_to_be16(f->fs.val.lport); + req->peer_port = cpu_to_be16(f->fs.val.fport); + req->local_ip_hi = *(__be64 *)(&f->fs.val.lip); + req->local_ip_lo = *(((__be64 *)&f->fs.val.lip) + 1); + req->peer_ip_hi = *(__be64 *)(&f->fs.val.fip); + req->peer_ip_lo = *(((__be64 *)&f->fs.val.fip) + 1); } static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb, unsigned int qid_filterid, struct adapter *adap) { struct cpl_t6_act_open_req *t6req = NULL; + struct cpl_t7_act_open_req *t7req = NULL; struct cpl_act_open_req *req = NULL; + u32 chip_ver; + __be32 opt2; + __be64 opt0; + + chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip); + + opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE || + f->fs.newvlan == VLAN_REWRITE) | + DELACK_V(f->fs.hitcnts) | + L2T_IDX_V(f->l2t ? f->l2t->idx : 0) | + SMAC_SEL_V((cxgb4_port_viid(f->dev) & + 0x7F) << 1) | + TX_CHAN_V(f->fs.eport) | + NO_CONG_V(f->fs.rpttid) | + ULP_MODE_V(f->fs.nat_mode ? + ULP_MODE_TCPDDP : ULP_MODE_NONE) | + TCAM_BYPASS_F | NON_OFFLOAD_F); + opt2 = cpu_to_be32(RSS_QUEUE_VALID_F | + RSS_QUEUE_V(f->fs.iq) | + TX_QUEUE_V(f->fs.nat_mode) | + T5_OPT_2_VALID_F | + RX_CHANNEL_V(cxgb4_hash_filter_rx_chan(adap, f)) | + PACE_V((f->fs.maskhash) | + ((f->fs.dirsteerhash) << 1))); + if (chip_ver >= CHELSIO_T7) { + t7req = (struct cpl_t7_act_open_req *)__skb_put_zero(skb, sizeof(*t7req)); + INIT_TP_WR(t7req, 0); + req = (struct cpl_act_open_req *)t7req; + t7req->opt0 = opt0; + t7req->opt2 = opt2; + t7req->params = cpu_to_be64(T7_FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev))); + } else { + t6req = (struct cpl_t6_act_open_req *)__skb_put_zero(skb, sizeof(*t6req)); + INIT_TP_WR(t6req, 0); + req = (struct cpl_act_open_req *)t6req; + t6req->opt0 = opt0; + t6req->opt2 = opt2; + t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev))); + } - t6req = (struct cpl_t6_act_open_req *)__skb_put(skb, sizeof(*t6req)); - INIT_TP_WR(t6req, 0); - req = (struct cpl_act_open_req *)t6req; OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, qid_filterid)); req->local_port = cpu_to_be16(f->fs.val.lport); req->peer_port = cpu_to_be16(f->fs.val.fport); memcpy(&req->local_ip, f->fs.val.lip, 4); memcpy(&req->peer_ip, f->fs.val.fip, 4); - req->opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE || - f->fs.newvlan == VLAN_REWRITE) | - DELACK_V(f->fs.hitcnts) | - L2T_IDX_V(f->l2t ? f->l2t->idx : 0) | - SMAC_SEL_V((cxgb4_port_viid(f->dev) & - 0x7F) << 1) | - TX_CHAN_V(f->fs.eport) | - NO_CONG_V(f->fs.rpttid) | - ULP_MODE_V(f->fs.nat_mode ? - ULP_MODE_TCPDDP : ULP_MODE_NONE) | - TCAM_BYPASS_F | NON_OFFLOAD_F); - - t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, - f->dev))); - t6req->opt2 = htonl(RSS_QUEUE_VALID_F | - RSS_QUEUE_V(f->fs.iq) | - TX_QUEUE_V(f->fs.nat_mode) | - T5_OPT_2_VALID_F | - RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) | - PACE_V((f->fs.maskhash) | - ((f->fs.dirsteerhash) << 1))); } static int cxgb4_set_hash_filter(struct net_device *dev, @@ -1461,7 +1536,8 @@ static int cxgb4_set_hash_filter(struct net_device *dev, } } - size = sizeof(struct cpl_t6_act_open_req); + /* Large enough for every CPL_ACT_OPEN_REQ variant built below */ + size = sizeof(struct cpl_t7_act_open_req6); if (f->fs.type) { ret = cxgb4_clip_get(f->dev, (const u32 *)&f->fs.val.lip, 1); if (ret) @@ -1663,7 +1739,7 @@ int __cxgb4_set_filter(struct net_device *dev, int ftid, if (ret) goto free_tid; - if (is_t6(adapter->params.chip) && fs->type && + if (chip_ver >= CHELSIO_T6 && fs->type && ipv6_addr_type((const struct in6_addr *)fs->val.lip) != IPV6_ADDR_ANY) { ret = cxgb4_clip_get(dev, (const u32 *)&fs->val.lip, 1); @@ -2140,12 +2216,13 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl) void init_hash_filter(struct adapter *adap) { - u32 reg; + u32 reg, chip_ver; + chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip); /* On T6, verify the necessary register configs and warn the user in * case of improper config */ - if (is_t6(adap->params.chip)) { + if (chip_ver >= CHELSIO_T6) { if (is_offload(adap)) { if (!(t4_read_reg(adap, TP_GLOBAL_CONFIG_A) & ACTIVEFILTERCOUNTS_F)) { diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index db018947d021..33ae94a975c9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -2925,13 +2925,17 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid, f->fs.val.lip[i] = val[i]; f->fs.mask.lip[i] = ~0; } - if (adap->params.tp.vlan_pri_map & PORT_F) { + /* The *_shift values are computed per chip in + * t4_init_tp_params() and are < 0 when the field is not part + * of the filter tuple. + */ + if (adap->params.tp.port_shift >= 0) { f->fs.val.iport = port; f->fs.mask.iport = mask; } } - if (adap->params.tp.vlan_pri_map & PROTOCOL_F) { + if (adap->params.tp.protocol_shift >= 0) { f->fs.val.proto = IPPROTO_TCP; f->fs.mask.proto = ~0; } -- 2.39.1