From: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
To: Himanshu Jha <himanshujha199640-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] IB/core: replace memcpy with ether_addr_copy
Date: Thu, 24 Aug 2017 10:41:16 -0700 [thread overview]
Message-ID: <1503596476.12569.6.camel@perches.com> (raw)
In-Reply-To: <20170824173103.GA13379@himanshu-Vostro-3559>
On Thu, 2017-08-24 at 23:01 +0530, Himanshu Jha wrote:
> On Thu, Aug 24, 2017 at 09:06:32AM -0700, Joe Perches wrote:
> > On Thu, 2017-08-24 at 21:11 +0530, Himanshu Jha wrote:
> > > Use ether_addr_copy to copy an ethernet address of size ETH_ALEN
> > > instead of memcpy.
> >
> > []
> > diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> > []
> > > @@ -798,7 +798,7 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
> > > if (ret)
> > > return ret;
> > >
> > > - memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN);
> > > + ether_addr_copy(dmac, dev_addr.dst_dev_addr);
> > > dev = dev_get_by_index(&init_net, dev_addr.bound_dev_if);
> > > if (!dev)
> > > return -ENODEV;
> > > @@ -831,7 +831,7 @@ int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id)
> > > if (ret)
> > > return ret;
> > >
> > > - memcpy(smac, dev_addr.src_dev_addr, ETH_ALEN);
> > > + ether_addr_copy(smac, dev_addr.src_dev_addr);
> > > return ret;
> > > }
> > > EXPORT_SYMBOL(rdma_addr_find_smac_by_sgid);
> >
> > Both dmac and smac are function arguments.
> > What guarantees these to be
> > aligned properly?
> >
>
> Yes, you are correct!
> The arguments should be a pointer to a six byte Ethernet address.
Just for completeness:
The argument should be a pointer to a 6 byte Ethernet address
which is also aligned to an even hardware address.
i.e.: u8 mac_addr[ETH_ALEN] __aligned(2);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Himanshu Jha <himanshujha199640@gmail.com>
Cc: dledford@redhat.com, sean.hefty@intel.com,
hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IB/core: replace memcpy with ether_addr_copy
Date: Thu, 24 Aug 2017 10:41:16 -0700 [thread overview]
Message-ID: <1503596476.12569.6.camel@perches.com> (raw)
In-Reply-To: <20170824173103.GA13379@himanshu-Vostro-3559>
On Thu, 2017-08-24 at 23:01 +0530, Himanshu Jha wrote:
> On Thu, Aug 24, 2017 at 09:06:32AM -0700, Joe Perches wrote:
> > On Thu, 2017-08-24 at 21:11 +0530, Himanshu Jha wrote:
> > > Use ether_addr_copy to copy an ethernet address of size ETH_ALEN
> > > instead of memcpy.
> >
> > []
> > diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> > []
> > > @@ -798,7 +798,7 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
> > > if (ret)
> > > return ret;
> > >
> > > - memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN);
> > > + ether_addr_copy(dmac, dev_addr.dst_dev_addr);
> > > dev = dev_get_by_index(&init_net, dev_addr.bound_dev_if);
> > > if (!dev)
> > > return -ENODEV;
> > > @@ -831,7 +831,7 @@ int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id)
> > > if (ret)
> > > return ret;
> > >
> > > - memcpy(smac, dev_addr.src_dev_addr, ETH_ALEN);
> > > + ether_addr_copy(smac, dev_addr.src_dev_addr);
> > > return ret;
> > > }
> > > EXPORT_SYMBOL(rdma_addr_find_smac_by_sgid);
> >
> > Both dmac and smac are function arguments.
> > What guarantees these to be
> > aligned properly?
> >
>
> Yes, you are correct!
> The arguments should be a pointer to a six byte Ethernet address.
Just for completeness:
The argument should be a pointer to a 6 byte Ethernet address
which is also aligned to an even hardware address.
i.e.: u8 mac_addr[ETH_ALEN] __aligned(2);
next prev parent reply other threads:[~2017-08-24 17:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 15:41 [PATCH] IB/core: replace memcpy with ether_addr_copy Himanshu Jha
2017-08-24 15:41 ` Himanshu Jha
2017-08-24 16:06 ` Joe Perches
[not found] ` <1503590792.12569.2.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2017-08-24 17:31 ` Himanshu Jha
2017-08-24 17:31 ` Himanshu Jha
2017-08-24 17:41 ` Joe Perches [this message]
2017-08-24 17:41 ` Joe Perches
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=1503596476.12569.6.camel@perches.com \
--to=joe-6d6dil74uinbdgjk7y7tuq@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=himanshujha199640-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.