RE: [PATCH v4 net-next] net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)

From: Haiyang Zhang
Date: Mon Apr 12 2021 - 10:39:56 EST




> -----Original Message-----
> From: Andrew Lunn <andrew@xxxxxxx>
> Sent: Monday, April 12, 2021 8:32 AM
> To: Dexuan Cui <decui@xxxxxxxxxxxxx>
> Cc: davem@xxxxxxxxxxxxx; kuba@xxxxxxxxxx; KY Srinivasan
> <kys@xxxxxxxxxxxxx>; Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>; Stephen
> Hemminger <sthemmin@xxxxxxxxxxxxx>; wei.liu@xxxxxxxxxx; Wei Liu
> <liuwe@xxxxxxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; leon@xxxxxxxxxx;
> bernd@xxxxxxxxxxxxxxxxxxx; rdunlap@xxxxxxxxxxxxx; Shachar Raindel
> <shacharr@xxxxxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; linux-
> hyperv@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v4 net-next] net: mana: Add a driver for Microsoft Azure
> Network Adapter (MANA)
>
> > +static void mana_gd_deregiser_irq(struct gdma_queue *queue) {
> > + struct gdma_dev *gd = queue->gdma_dev;
> > + struct gdma_irq_context *gic;
> > + struct gdma_context *gc;
> > + struct gdma_resource *r;
> > + unsigned int msix_index;
> > + unsigned long flags;
> > +
> > + /* At most num_online_cpus() + 1 interrupts are used. */
> > + msix_index = queue->eq.msix_index;
> > + if (WARN_ON(msix_index > num_online_cpus()))
> > + return;
>
> Do you handle hot{un}plug of CPUs?
We don't have hot{un}plug of CPU feature yet.

>
> > +static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue
> *q_self,
> > + struct gdma_event *event)
> > +{
> > + struct hw_channel_context *hwc = ctx;
> > + struct gdma_dev *gd = hwc->gdma_dev;
> > + union hwc_init_type_data type_data;
> > + union hwc_init_eq_id_db eq_db;
> > + u32 type, val;
> > +
> > + switch (event->type) {
> > + case GDMA_EQE_HWC_INIT_EQ_ID_DB:
> > + eq_db.as_uint32 = event->details[0];
> > + hwc->cq->gdma_eq->id = eq_db.eq_id;
> > + gd->doorbell = eq_db.doorbell;
> > + break;
> > +
> > + case GDMA_EQE_HWC_INIT_DATA:
> > +
> > + type_data.as_uint32 = event->details[0];
> > +
> > + case GDMA_EQE_HWC_INIT_DONE:
> > + complete(&hwc->hwc_init_eqe_comp);
> > + break;
>
> ...
>
> > + default:
> > + WARN_ON(1);
> > + break;
> > + }
>
> Are these events from the firmware? If you have newer firmware with an
> older driver, are you going to spam the kernel log with WARN_ON dumps?
For protocol version mismatch, the host and guest will either negotiate the
highest common version, or fail to probe. So this kind of warnings are not
expected.

>
> > +static int mana_move_wq_tail(struct gdma_queue *wq, u32 num_units) {
> > + u32 used_space_old;
> > + u32 used_space_new;
> > +
> > + used_space_old = wq->head - wq->tail;
> > + used_space_new = wq->head - (wq->tail + num_units);
> > +
> > + if (used_space_new > used_space_old) {
> > + WARN_ON(1);
> > + return -ERANGE;
> > + }
>
> You could replace the 1 by the condition. There are a couple of these.
Will do.

Thanks,
- Haiyang