From: Jason Gunthorpe <jgg@nvidia.com>
To: liweihang <liweihang@huawei.com>
Cc: "dledford@redhat.com" <dledford@redhat.com>,
"leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"linuxarm@openeuler.org" <linuxarm@openeuler.org>
Subject: Re: [PATCH for-next 1/2] RDMA/hns: Support query information of functions from FW
Date: Wed, 24 Mar 2021 09:06:34 -0300 [thread overview]
Message-ID: <20210324120634.GU2356281@nvidia.com> (raw)
In-Reply-To: <74c5373f541f4f3282795f7763f198da@huawei.com>
On Wed, Mar 24, 2021 at 03:07:47AM +0000, liweihang wrote:
> On 2021/3/24 9:55, liweihang wrote:
> > On 2021/3/24 3:56, Jason Gunthorpe wrote:
> >> On Fri, Mar 12, 2021 at 05:48:26PM +0800, Weihang Li wrote:
> >>
> >>> +static int hns_roce_query_func_info(struct hns_roce_dev *hr_dev)
> >>> +{
> >>> + struct hns_roce_pf_func_info *resp;
> >>> + struct hns_roce_cmq_desc desc;
> >>> + int ret;
> >>> +
> >>> + if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09)
> >>> + return 0;
> >>> +
> >>> + hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_QUERY_FUNC_INFO,
> >>> + true);
> >>> + ret = hns_roce_cmq_send(hr_dev, &desc, 1);
> >>> + if (ret)
> >>> + return ret;
> >>> +
> >>> + resp = (struct hns_roce_pf_func_info *)desc.data;
> >>
> >> WTF is this cast?
> >>
> >> struct hns_roce_cmq_desc {
> >> __le16 opcode;
> >> __le16 flag;
> >> __le16 retval;
> >> __le16 rsv;
> >> __le32 data[6];
> >> };
> >>
> >> Casting __le32 to a pointer is wrong
> >>
> >> Jason
> >>
> >
> > Hi Jason
> >
> > desc.data is the address of array 'data[6]', it is got from the firmware, we
> > cast it to 'struct hns_roce_pf_func_info *' to parse its contents. I think this
> > is a cast from '__le32 *' to 'struct hns_roce_pf_func_info *'.
> >
> > Thanks
> > Weihang
> >
> >
>
> Jason, do you mean the current code is not written correctly? Do you have any
> suggestions for achieving our purpose?
Use a union
Jason
next prev parent reply other threads:[~2021-03-24 12:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 9:48 [PATCH for-next 0/2] RDMA/hns: Support to select congestion control algorithm Weihang Li
2021-03-12 9:48 ` [PATCH for-next 1/2] RDMA/hns: Support query information of functions from FW Weihang Li
2021-03-23 19:56 ` Jason Gunthorpe
2021-03-24 1:54 ` liweihang
2021-03-24 3:07 ` liweihang
2021-03-24 12:06 ` Jason Gunthorpe [this message]
2021-03-12 9:48 ` [PATCH for-next 2/2] RDMA/hns: Support congestion control type selection according to the FW Weihang Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210324120634.GU2356281@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@openeuler.org \
--cc=liweihang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox