On Mon, Dec 31, 2018 at 01:10:01AM -0500, Devesh Sharma wrote: > Adding setup and destroy routines for chip-context. The > chip context would be used frequently in control and data > path to take execution flow depending on the chip type. > chip context structure pointer is added to the relevant > data structures. > > Signed-off-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx> > Signed-off-by: Devesh Sharma <devesh.sharma@xxxxxxxxxxxx> > drivers/infiniband/hw/bnxt_re/bnxt_re.h | 1 + > drivers/infiniband/hw/bnxt_re/main.c | 43 ++++++++++++++++++++++++++++++ > drivers/infiniband/hw/bnxt_re/qplib_fp.h | 1 + > drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 1 + > drivers/infiniband/hw/bnxt_re/qplib_res.h | 15 ++++++++++- > 5 files changed, 60 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h > index 31baa893..6c16515 100644 > +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h > @@ -124,6 +124,7 @@ struct bnxt_re_dev { > #define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29 > struct net_device *netdev; > unsigned int version, major, minor; > + struct bnxt_qplib_chip_ctx *chip_ctx; > struct bnxt_en_dev *en_dev; > struct bnxt_msix_entry msix_entries[BNXT_RE_MAX_MSIX]; > int num_msix; > diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c > index e7a997f..e3e1944 100644 > +++ b/drivers/infiniband/hw/bnxt_re/main.c > @@ -80,6 +80,38 @@ > static struct workqueue_struct *bnxt_re_wq; > static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev); > > +static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev) > +{ > + struct bnxt_qplib_chip_ctx *chip_ctx; > + > + chip_ctx = rdev->chip_ctx; > + rdev->chip_ctx = NULL; > + rdev->rcfw.res = NULL; > + rdev->qplib_res.cctx = NULL; > + kfree(chip_ctx); > +} > + > +static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev) > +{ > + struct bnxt_qplib_chip_ctx *chip_ctx; > + struct bnxt_en_dev *en_dev; > + struct bnxt *bp; > + > + en_dev = rdev->en_dev; > + bp = netdev_priv(en_dev->net); > + > + chip_ctx = kzalloc(sizeof(*chip_ctx), GFP_KERNEL); > + if (!chip_ctx) > + return -ENOMEM; It seems a bit weird to kzalloc this? Why not just inline it in the rdev struct? Jason