lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANXQDtaKPerCir9PGddZ3YDf-0MhjtBu4hXgRew93Xj42V2bzA@mail.gmail.com>
Date: Fri, 16 Jan 2026 23:58:01 +0530
From: Bhargava Chenna Marreddy <bhargava.marreddy@...adcom.com>
To: ALOK TIWARI <alok.a.tiwari@...cle.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org, 
	pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
	michael.chan@...adcom.com, pavan.chebbi@...adcom.com, 
	vsrama-krishna.nemani@...adcom.com, vikas.gupta@...adcom.com, 
	Rajashekar Hudumula <rajashekar.hudumula@...adcom.com>
Subject: Re: [v4, net-next 2/7] bng_en: Add RX support

On Fri, Jan 16, 2026 at 10:36 PM ALOK TIWARI <alok.a.tiwari@...cle.com> wrote:
>
>
>
> On 1/5/2026 12:51 PM, Bhargava Marreddy wrote:
> > Add support to receive packet using NAPI, build and deliver the skb
> > to stack. With help of meta data available in completions, fill the
> > appropriate information in skb.
> >
> > Signed-off-by: Bhargava Marreddy <bhargava.marreddy@...adcom.com>
> > Reviewed-by: Vikas Gupta <vikas.gupta@...adcom.com>
> > Reviewed-by: Rajashekar Hudumula <rajashekar.hudumula@...adcom.com>
> > ---
> >   drivers/net/ethernet/broadcom/bnge/Makefile   |   3 +-
> >   .../net/ethernet/broadcom/bnge/bnge_hw_def.h  | 198 ++++++
> >   .../net/ethernet/broadcom/bnge/bnge_netdev.c  | 113 +++-
> >   .../net/ethernet/broadcom/bnge/bnge_netdev.h  |  60 +-
> >   .../net/ethernet/broadcom/bnge/bnge_txrx.c    | 573 ++++++++++++++++++
> >   .../net/ethernet/broadcom/bnge/bnge_txrx.h    |  90 +++
> >   6 files changed, 1016 insertions(+), 21 deletions(-)
> >   create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_hw_def.h
> >   create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_txrx.c
> >   create mode 100644 drivers/net/ethernet/broadcom/bnge/bnge_txrx.h
> >
> > +
> > +static int __bnge_poll_work(struct bnge_net *bn, struct bnge_cp_ring_info *cpr,
> > +                         int budget)
> > +{
> > +     struct bnge_napi *bnapi = cpr->bnapi;
> > +     u32 raw_cons = cpr->cp_raw_cons;
> > +     struct tx_cmp *txcmp;
> > +     int rx_pkts = 0;
> > +     u8 event = 0;
> > +     u32 cons;
> > +
> > +     cpr->has_more_work = 0;
> > +     cpr->had_work_done = 1;
> > +     while (1) {
> > +             u8 cmp_type;
> > +             int rc;
> > +
> > +             cons = RING_CMP(bn, raw_cons);
> > +             txcmp = &cpr->desc_ring[CP_RING(cons)][CP_IDX(cons)];
> > +
> > +             if (!TX_CMP_VALID(bn, txcmp, raw_cons))
> > +                     break;
> > +
> > +             /* The valid test of the entry must be done first before
> > +              * reading any further.
> > +              */
> > +             dma_rmb();
> > +             cmp_type = TX_CMP_TYPE(txcmp);
> > +             if (cmp_type == CMP_TYPE_TX_L2_CMP ||
> > +                 cmp_type == CMP_TYPE_TX_L2_COAL_CMP) {
> > +                     /*
> > +                      * Tx Compl Processng
>
> typo -> Processng

Thanks, Alok. I will fix the typo in the next spin.

>
> > +                      */
> > +             } else if (cmp_type >= CMP_TYPE_RX_L2_CMP &&
> > +                        cmp_type <= CMP_TYPE_RX_L2_TPA_START_V3_CMP) {
> > +                     if (likely(budget))
> > +                             rc = bnge_rx_pkt(bn, cpr, &raw_cons, &event);
> > +                     else
> > +                             rc = bnge_force_rx_discard(bn, cpr, &raw_cons,
> > +                                                        &event);
> > +                     if (likely(rc >= 0))
> > +                             rx_pkts += rc;
> > +                     /* Increment rx_pkts when rc is -ENOMEM to count towards
> > +                      * the NAPI budget.  Otherwise, we may potentially loop
> > +                      * here forever if we consistently cannot allocate
> > +                      * buffers.
> > +                      */
> > +                     else if (rc == -ENOMEM && budget)
> > +                             rx_pkts++;
> > +                     else if (rc == -EBUSY)  /* partial completion */
> > +                             break;
> > +             }
> > +
> > +             raw_cons = NEXT_RAW_CMP(raw_cons);
> > +
> > +             if (rx_pkts && rx_pkts == budget) {
> > +                     cpr->has_more_work = 1;
> > +                     break;
> > +             }
> > +     }
> > +
> > +     cpr->cp_raw_cons = raw_cons;
> > +     bnapi->events |= event;
> > +     return rx_pkts;
> > +}
> > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_txrx.h b/drivers/net/ethernet/broadcom/bnge/bnge_txrx.h
> > new file mode 100644
> > index 000000000000..b13081b0eb79
> > --- /dev/null
> > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_txrx.h
> > @@ -0,0 +1,90 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/* Copyright (c) 2025 Broadcom */
> > +
> > +#ifndef _BNGE_TXRX_H_
> > +#define _BNGE_TXRX_H_
> > +
> > +#include <linux/bnxt/hsi.h>
> > +#include "bnge_netdev.h"
> > +
> > +#define BNGE_MIN_PKT_SIZE    52
> > +
> > +#define TX_OPAQUE_IDX_MASK   0x0000ffff
> > +#define TX_OPAQUE_BDS_MASK   0x00ff0000
> > +#define TX_OPAQUE_BDS_SHIFT  16
> > +#define TX_OPAQUE_RING_MASK  0xff000000
> > +#define TX_OPAQUE_RING_SHIFT 24
> > +
> > +#define SET_TX_OPAQUE(bn, txr, idx, bds)                             \
> > +     (((txr)->tx_napi_idx << TX_OPAQUE_RING_SHIFT) |                 \
> > +      ((bds) << TX_OPAQUE_BDS_SHIFT) | ((idx) & (bn)->tx_ring_mask))
> > +
> > +#define TX_OPAQUE_IDX(opq)   ((opq) & TX_OPAQUE_IDX_MASK)
> > +#define TX_OPAQUE_RING(opq)  (((opq) & TX_OPAQUE_RING_MASK) >>       \
> > +                              TX_OPAQUE_RING_SHIFT)
> > +#define TX_OPAQUE_BDS(opq)   (((opq) & TX_OPAQUE_BDS_MASK) >>        \
> > +                              TX_OPAQUE_BDS_SHIFT)
> > +#define TX_OPAQUE_PROD(bn, opq)      ((TX_OPAQUE_IDX(opq) + TX_OPAQUE_BDS(opq)) &\
> > +                              (bn)->tx_ring_mask)
> > +
> > +/* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1.  We need one extra
> > + * BD because the first TX BD is always a long BD.
> > + */
> > +#define BNGE_MIN_TX_DESC_CNT         (MAX_SKB_FRAGS + 2)
> > +
> > +#define RX_RING(bn, x)       (((x) & (bn)->rx_ring_mask) >> (BNGE_PAGE_SHIFT - 4))
> > +#define RX_AGG_RING(bn, x)   (((x) & (bn)->rx_agg_ring_mask) >>      \
> > +                              (BNGE_PAGE_SHIFT - 4))
> > +#define RX_IDX(x)    ((x) & (RX_DESC_CNT - 1))
> > +
> > +#define TX_RING(bn, x)       (((x) & (bn)->tx_ring_mask) >> (BNGE_PAGE_SHIFT - 4))
> > +#define TX_IDX(x)    ((x) & (TX_DESC_CNT - 1))
> > +
> > +#define CP_RING(x)   (((x) & ~(CP_DESC_CNT - 1)) >> (BNGE_PAGE_SHIFT - 4))
> > +#define CP_IDX(x)    ((x) & (CP_DESC_CNT - 1))
> > +
> > +#define TX_CMP_VALID(bn, txcmp, raw_cons)                            \
> > +     (!!((txcmp)->tx_cmp_errors_v & cpu_to_le32(TX_CMP_V)) ==        \
> > +      !((raw_cons) & (bn)->cp_bit))
> > +
> > +#define RX_CMP_VALID(rxcmp1, raw_cons)                                       \
> > +     (!!((rxcmp1)->rx_cmp_cfa_code_errors_v2 & cpu_to_le32(RX_CMP_V)) ==\
> > +      !((raw_cons) & (bn)->cp_bit))
>
> bn is not defined in macro

Ack, I will fix it in the next spin.

Thanks,
Bhargava Marreddy

>
> > +
> > +#define RX_AGG_CMP_VALID(bn, agg, raw_cons)                  \
> > +     (!!((agg)->rx_agg_cmp_v & cpu_to_le32(RX_AGG_CMP_V)) == \
> > +      !((raw_cons) & (bn)->cp_bit))
> > +
> > +#define NQ_CMP_VALID(bn, nqcmp, raw_cons)                            \
> > +     (!!((nqcmp)->v & cpu_to_le32(NQ_CN_V)) == !((raw_cons) & (bn)->cp_bit))
> > +
> > +#define TX_CMP_TYPE(txcmp)                                   \
> > +     (le32_to_cpu((txcmp)->tx_cmp_flags_type) & CMP_TYPE)
> > +
>
> Thanks,
> Alok

Download attachment "smime.p7s" of type "application/pkcs7-signature" (5496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ