From patchwork Thu Jun 10 19:04:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Petrilin X-Patchwork-Id: 105439 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5AJ4WSt016592 for ; Thu, 10 Jun 2010 19:04:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759705Ab0FJTE6 (ORCPT ); Thu, 10 Jun 2010 15:04:58 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:41837 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759692Ab0FJTE5 (ORCPT ); Thu, 10 Jun 2010 15:04:57 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yevgenyp@mellanox.co.il) with SMTP; 10 Jun 2010 22:05:46 +0300 Received: from vnc8.lab.mtl.com ([10.4.45.8]) by mtlexch01.mtl.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Jun 2010 22:04:54 +0300 Message-ID: <4C113756.50307@mellanox.co.il> Date: Thu, 10 Jun 2010 22:04:54 +0300 From: Yevgeny Petrilin User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Roland Dreier CC: linux-rdma@vger.kernel.org Subject: [PATCH 13/19 V4] mlx4_core: Giving Mac addresses for slave functions. X-OriginalArrivalTime: 10 Jun 2010 19:04:54.0977 (UTC) FILETIME=[CFEBA310:01CB08CF] X-TM-AS-Product-Ver: SMEX-8.0.0.1181-6.000.1038-17438.001 X-TM-AS-Result: No--7.165000-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 10 Jun 2010 19:04:58 +0000 (UTC) diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c index e53a392..773de63 100644 --- a/drivers/net/mlx4/fw.c +++ b/drivers/net/mlx4/fw.c @@ -32,6 +32,7 @@ * SOFTWARE. */ +#include #include #include @@ -136,6 +137,45 @@ int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg) return err; } +int mlx4_QUERY_VEP_CFG(struct mlx4_dev *dev, u8 vep_num, + struct mlx4_vep_cfg *cfg) +{ + int err; + u32 in_mod; + u64 output; + +#define QUERY_VEP_CFG_OPMOD 3 + +#define QUERY_VEP_CFG_INMOD (2 << 28) +#define QUERY_VEP_CFG_INMOD_VEP_OFFSET 16 + +#define QUERY_VEP_CFG_MAC_OFFSET 0x90 +#define QUERY_VEP_CFG_LINK_OFFSET 0xa0 + + + in_mod = QUERY_VEP_CFG_INMOD | (vep_num << QUERY_VEP_CFG_INMOD_VEP_OFFSET); + + err = mlx4_cmd_imm(dev, 0, &output, in_mod | QUERY_VEP_CFG_MAC_OFFSET, + QUERY_VEP_CFG_OPMOD, MLX4_CMD_MOD_STAT_CFG, + MLX4_CMD_TIME_CLASS_A); + if (err) { + mlx4_err(dev, "Failed to retrieve mac for function %d\n", vep_num); + return err; + } + cfg->mac = output & 0xffffffffffffULL; + + err = mlx4_cmd_imm(dev, 0, &output, in_mod | QUERY_VEP_CFG_LINK_OFFSET, + QUERY_VEP_CFG_OPMOD, MLX4_CMD_MOD_STAT_CFG, + MLX4_CMD_TIME_CLASS_A); + if (err) { + mlx4_err(dev, "Failed to retrieve link for function %d\n", vep_num); + return err; + } + cfg->link = (output >> 32) & 1; + + return 0; +} + int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, struct mlx4_cmd_mailbox *outbox) @@ -148,10 +188,34 @@ int mlx4_QUERY_SLAVE_CAP_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vh struct mlx4_cmd_mailbox *inbox, struct mlx4_cmd_mailbox *outbox) { + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master; + struct mlx4_slave_state *slave_st = &master->slave_state[slave]; struct mlx4_caps *caps = outbox->buf; + struct mlx4_vep_cfg cfg; + u8 pf_num = slave_st->pf_num; + u8 rand_mac[6]; + int i, j, err = 0; memcpy(caps, &dev->caps, sizeof *caps); + /* For physical functions Mac should be defined by fw */ + if (pf_num == slave) { + err = mlx4_QUERY_VEP_CFG(dev, pf_num, &cfg); + if (err) + mlx4_warn(dev, "Failed to retreive mac address for vep %d\n", pf_num); + else + caps->def_mac[(pf_num & 1) + 1] = cfg.mac; + } + if (pf_num != slave || err) { + 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; j++) + caps->def_mac[i] |= ((u64)(rand_mac[1]) << 8 * j); + } + } + /* Ports are activated according to physical function number */ mlx4_set_port_mask(dev, caps, slave); diff --git a/drivers/net/mlx4/fw.h b/drivers/net/mlx4/fw.h index d5c17cf..f8d49d0 100644 --- a/drivers/net/mlx4/fw.h +++ b/drivers/net/mlx4/fw.h @@ -43,6 +43,11 @@ struct mlx4_mod_stat_cfg { u8 log_pg_sz_m; }; +struct mlx4_vep_cfg { + u64 mac; + u8 link; +}; + struct mlx4_dev_cap { int max_srq_sz; int max_qp_sz; @@ -180,6 +185,7 @@ int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm); int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev); int mlx4_NOP(struct mlx4_dev *dev); int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg); +int mlx4_QUERY_VEP_CFG(struct mlx4_dev *dev, u8 vep_num, struct mlx4_vep_cfg *cfg); int mlx4_QUERY_FUNC(struct mlx4_dev *dev, int func, u8 *pf_num); #endif /* MLX4_FW_H */