Re: [PATCH for-next 1/8] RDMA/erdma: Probe the erdma RoCEv2 device

Boshi Yu
2024-12-05T02:46:51Z

在 2024/12/4 22:03, Leon Romanovsky 写道:
> On Tue, Nov 26, 2024 at 02:59:07PM +0800, Boshi Yu wrote:
>> Currently, the erdma driver supports both the iWARP and RoCEv2 protocols.
>> The erdma driver reads the ERDMA_REGS_DEV_PROTO_REG register to identify
>> the protocol used by the erdma device. Since each protocol requires
>> different ib_device_ops, we introduce the erdma_device_ops_iwarp and
>> erdma_device_ops_rocev2 for iWARP and RoCEv2 protocols, respectively.
>>
>> Signed-off-by: Boshi Yu <boshiyu@linux.alibaba.com>
>> Reviewed-by: Cheng Xu <chengyou@linux.alibaba.com>
>> ---
>> drivers/infiniband/hw/erdma/Kconfig | 2 +-
>> drivers/infiniband/hw/erdma/erdma.h | 3 +-
>> drivers/infiniband/hw/erdma/erdma_hw.h | 7 ++++
>> drivers/infiniband/hw/erdma/erdma_main.c | 47 ++++++++++++++++++-----
>> drivers/infiniband/hw/erdma/erdma_verbs.c | 16 +++++++-
>> drivers/infiniband/hw/erdma/erdma_verbs.h | 12 ++++++
>> 6 files changed, 75 insertions(+), 12 deletions(-)
>
> <...>
>
>> +++ b/drivers/infiniband/hw/erdma/erdma_main.c
>> @@ -172,6 +172,12 @@ static int erdma_device_init(struct erdma_dev *dev, struct pci_dev *pdev)
>> {
>> int ret;
>>
>> + dev->proto = erdma_reg_read32(dev, ERDMA_REGS_DEV_PROTO_REG);
>> + if (!erdma_device_iwarp(dev) && !erdma_device_rocev2(dev)) {
>
> Why do you need this check? Your old driver which supports only iwarp
> doesn't have this check, so why did you suddenly need it for roce?
>

Hi, Leon,

We initially try to avoid reading an invalid value from the hardware.
Thank you for your question; I found that the check is unnecessary since
the value of ERDMA_REGS_DEV_PROTO_REG can only be 0 or 1. We will remove
this check in patch v2.

Thanks,

Boshi Yu

>> + dev_err(&pdev->dev, "Unsupported protocol: %d\n", dev->proto);
>> + return -ENODEV;
>> + }
>> +
>
> Thanks