Re: [PATCH net-next 4/4] vmxnet3: update to version 9

Simon Horman
2024-05-15T10:49:20Z

On Tue, May 14, 2024 at 11:20:49AM -0700, Ronak Doshi wrote:
> With all vmxnet3 version 9 changes incorporated in the vmxnet3 driver,
> the driver can configure emulation to run at vmxnet3 version 9, provided
> the emulation advertises support for version 9.
>
> Signed-off-by: Ronak Doshi <ronak.doshi@broadcom.com>
> Acked-by: Guolin Yang <guolin.yang@broadcom.com>

...

> @@ -4019,42 +4019,14 @@ vmxnet3_probe_device(struct pci_dev *pdev,
> goto err_alloc_pci;
>
> ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS);
> - if (ver & (1 << VMXNET3_REV_7)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_7);
> - adapter->version = VMXNET3_REV_7 + 1;
> - } else if (ver & (1 << VMXNET3_REV_6)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_6);
> - adapter->version = VMXNET3_REV_6 + 1;
> - } else if (ver & (1 << VMXNET3_REV_5)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_5);
> - adapter->version = VMXNET3_REV_5 + 1;
> - } else if (ver & (1 << VMXNET3_REV_4)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_4);
> - adapter->version = VMXNET3_REV_4 + 1;
> - } else if (ver & (1 << VMXNET3_REV_3)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_3);
> - adapter->version = VMXNET3_REV_3 + 1;
> - } else if (ver & (1 << VMXNET3_REV_2)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_2);
> - adapter->version = VMXNET3_REV_2 + 1;
> - } else if (ver & (1 << VMXNET3_REV_1)) {
> - VMXNET3_WRITE_BAR1_REG(adapter,
> - VMXNET3_REG_VRRS,
> - 1 << VMXNET3_REV_1);
> - adapter->version = VMXNET3_REV_1 + 1;
> - } else {
> + for (i = VMXNET3_REV_9; i >= VMXNET3_REV_1; i--) {
> + if (ver & (1 << i)) {
> + VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_VRRS, 1 << i);

nit: Please consider using the BIT() macro.

> + adapter->version = i + 1;
> + break;
> + }
> + }
> + if (i < VMXNET3_REV_1) {
> dev_err(&pdev->dev,
> "Incompatible h/w version (0x%x) for adapter\n", ver);
> err = -EBUSY;