Message ID | 4B6AEE38.4010207@mellanox.co.il |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 2010-02-04 at 17:56 +0200, Yevgeny Petrilin wrote: > Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> > --- > drivers/net/mlx4/fw.c | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c > index 6e3e1d1..202a256 100644 > --- a/drivers/net/mlx4/fw.c > +++ b/drivers/net/mlx4/fw.c > @@ -32,6 +32,7 @@ > * SOFTWARE. > */ > > +#include <linux/etherdevice.h> > #include <linux/mlx4/cmd.h> > #include <linux/cache.h> > > @@ -149,11 +150,19 @@ int mlx4_QUERY_SLAVE_CAP_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vh > struct mlx4_cmd_mailbox *outbox) > { > struct mlx4_caps *caps = outbox->buf; > + u8 rand_mac[6]; > + int i, j; > > memcpy(caps, &dev->caps, sizeof *caps); > > /* The Master function is in charge for qp1 of al slaves */ > caps->sqp_demux = 0; > + for (i = 1; i <= dev->caps.num_ports; ++i) { > + random_ether_addr(rand_mac); > + caps->def_mac[i] = 0; > + for (j = 0; j < ETH_ALEN - 1; j++) > + caps->def_mac[i] |= ((u64)(rand_mac[j]) << 8 * j); [...] Do you really want the last byte to be 0 always? Assuming you don't, you can avoid the inner loop by writing: union { u8 bytes[ETH_ALEN]; __le64 qword; } rand_mac = { .qword = 0 }; ... random_ether_addr(rand_mac.bytes); caps->def_mac[i] = le64_to_cpup(&rand_mac.qword); Ben.
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c index 6e3e1d1..202a256 100644 --- a/drivers/net/mlx4/fw.c +++ b/drivers/net/mlx4/fw.c @@ -32,6 +32,7 @@ * SOFTWARE. */ +#include <linux/etherdevice.h> #include <linux/mlx4/cmd.h> #include <linux/cache.h> @@ -149,11 +150,19 @@ int mlx4_QUERY_SLAVE_CAP_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vh struct mlx4_cmd_mailbox *outbox) { struct mlx4_caps *caps = outbox->buf; + u8 rand_mac[6]; + int i, j; memcpy(caps, &dev->caps, sizeof *caps); /* The Master function is in charge for qp1 of al slaves */ caps->sqp_demux = 0; + for (i = 1; i <= dev->caps.num_ports; ++i) { + random_ether_addr(rand_mac); + caps->def_mac[i] = 0; + for (j = 0; j < ETH_ALEN - 1; j++) + caps->def_mac[i] |= ((u64)(rand_mac[j]) << 8 * j); + } /* Ports are activated according to physical function number */ mlx4_set_port_mask(dev, caps, slave);
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> --- drivers/net/mlx4/fw.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)