Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b230ed8 authored by Rasesh Mody's avatar Rasesh Mody Committed by David S. Miller
Browse files

bna: Brocade 10Gb Ethernet device driver



This is patch 1/6 which contains linux driver source for
Brocade's BR1010/BR1020 10Gb CEE capable ethernet adapter.

Signed-off-by: default avatarDebashis Dutt <ddutt@brocade.com>
Signed-off-by: default avatarRasesh Mody <rmody@brocade.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 231cc2aa
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1387,6 +1387,13 @@ L: linux-scsi@vger.kernel.org
S:	Supported
F:	drivers/scsi/bfa/

BROCADE BNA 10 GIGABIT ETHERNET DRIVER
M:	Rasesh Mody <rmody@brocade.com>
M:	Debashis Dutt <ddutt@brocade.com>
L:	netdev@vger.kernel.org
S:	Supported
F:	drivers/net/bna/

BSG (block layer generic sg v4 driver)
M:	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
L:	linux-scsi@vger.kernel.org
+14 −0
Original line number Diff line number Diff line
@@ -2869,6 +2869,20 @@ config QLGE
	  To compile this driver as a module, choose M here: the module
	  will be called qlge.

config BNA
        tristate "Brocade 1010/1020 10Gb Ethernet Driver support"
        depends on PCI
        ---help---
          This driver supports Brocade 1010/1020 10Gb CEE capable Ethernet
          cards.
          To compile this driver as a module, choose M here: the module
          will be called bna.

          For general information and support, go to the Brocade support
          website at:

          <http://support.brocade.com>

source "drivers/net/sfc/Kconfig"

source "drivers/net/benet/Kconfig"
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ obj-$(CONFIG_ENIC) += enic/
obj-$(CONFIG_JME) += jme.o
obj-$(CONFIG_BE2NET) += benet/
obj-$(CONFIG_VMXNET3) += vmxnet3/
obj-$(CONFIG_BNA) += bna/

gianfar_driver-objs := gianfar.o \
		gianfar_ethtool.o \
+11 −0
Original line number Diff line number Diff line
#
# Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
# All rights reserved.
#

obj-$(CONFIG_BNA) += bna.o

bna-objs := bnad.o bnad_ethtool.o bna_ctrl.o bna_txrx.o
bna-objs += bfa_ioc.o bfa_ioc_ct.o bfa_cee.o cna_fwimg.o

EXTRA_CFLAGS := -Idrivers/net/bna
+407 −0
Original line number Diff line number Diff line
/*
 * Linux network driver for Brocade Converged Network Adapter.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License (GPL) Version 2 as
 * published by the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */
/*
 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
 * All rights reserved
 * www.brocade.com
 */

#include "bfa_defs_cna.h"
#include "cna.h"
#include "bfa_cee.h"
#include "bfi_cna.h"
#include "bfa_ioc.h"

#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc)

static void bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg *lldp_cfg);
static void bfa_cee_format_cee_cfg(void *buffer);

static void
bfa_cee_format_cee_cfg(void *buffer)
{
	struct bfa_cee_attr *cee_cfg = buffer;
	bfa_cee_format_lldp_cfg(&cee_cfg->lldp_remote);
}

static void
bfa_cee_stats_swap(struct bfa_cee_stats *stats)
{
	u32 *buffer = (u32 *)stats;
	int i;

	for (i = 0; i < (sizeof(struct bfa_cee_stats) / sizeof(u32));
		i++) {
		buffer[i] = ntohl(buffer[i]);
	}
}

static void
bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg *lldp_cfg)
{
	lldp_cfg->time_to_live =
			ntohs(lldp_cfg->time_to_live);
	lldp_cfg->enabled_system_cap =
			ntohs(lldp_cfg->enabled_system_cap);
}

/**
 * bfa_cee_attr_meminfo()
 *
 * @brief Returns the size of the DMA memory needed by CEE attributes
 *
 * @param[in] void
 *
 * @return Size of DMA region
 */
static u32
bfa_cee_attr_meminfo(void)
{
	return roundup(sizeof(struct bfa_cee_attr), BFA_DMA_ALIGN_SZ);
}
/**
 * bfa_cee_stats_meminfo()
 *
 * @brief Returns the size of the DMA memory needed by CEE stats
 *
 * @param[in] void
 *
 * @return Size of DMA region
 */
static u32
bfa_cee_stats_meminfo(void)
{
	return roundup(sizeof(struct bfa_cee_stats), BFA_DMA_ALIGN_SZ);
}

/**
 * bfa_cee_get_attr_isr()
 *
 * @brief CEE ISR for get-attributes responses from f/w
 *
 * @param[in] cee - Pointer to the CEE module
 *            status - Return status from the f/w
 *
 * @return void
 */
static void
bfa_cee_get_attr_isr(struct bfa_cee *cee, enum bfa_status status)
{
	cee->get_attr_status = status;
	if (status == BFA_STATUS_OK) {
		memcpy(cee->attr, cee->attr_dma.kva,
		    sizeof(struct bfa_cee_attr));
		bfa_cee_format_cee_cfg(cee->attr);
	}
	cee->get_attr_pending = false;
	if (cee->cbfn.get_attr_cbfn)
		cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
}

/**
 * bfa_cee_get_attr_isr()
 *
 * @brief CEE ISR for get-stats responses from f/w
 *
 * @param[in] cee - Pointer to the CEE module
 *            status - Return status from the f/w
 *
 * @return void
 */
static void
bfa_cee_get_stats_isr(struct bfa_cee *cee, enum bfa_status status)
{
	cee->get_stats_status = status;
	if (status == BFA_STATUS_OK) {
		memcpy(cee->stats, cee->stats_dma.kva,
			sizeof(struct bfa_cee_stats));
		bfa_cee_stats_swap(cee->stats);
	}
	cee->get_stats_pending = false;
	if (cee->cbfn.get_stats_cbfn)
		cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
}

/**
 * bfa_cee_get_attr_isr()
 *
 * @brief CEE ISR for reset-stats responses from f/w
 *
 * @param[in] cee - Pointer to the CEE module
 *            status - Return status from the f/w
 *
 * @return void
 */
static void
bfa_cee_reset_stats_isr(struct bfa_cee *cee, enum bfa_status status)
{
	cee->reset_stats_status = status;
	cee->reset_stats_pending = false;
	if (cee->cbfn.reset_stats_cbfn)
		cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
}
/**
 * bfa_cee_meminfo()
 *
 * @brief Returns the size of the DMA memory needed by CEE module
 *
 * @param[in] void
 *
 * @return Size of DMA region
 */
u32
bfa_cee_meminfo(void)
{
	return bfa_cee_attr_meminfo() + bfa_cee_stats_meminfo();
}

/**
 * bfa_cee_mem_claim()
 *
 * @brief Initialized CEE DMA Memory
 *
 * @param[in] cee CEE module pointer
 *	      dma_kva Kernel Virtual Address of CEE DMA Memory
 *	      dma_pa  Physical Address of CEE DMA Memory
 *
 * @return void
 */
void
bfa_cee_mem_claim(struct bfa_cee *cee, u8 *dma_kva, u64 dma_pa)
{
	cee->attr_dma.kva = dma_kva;
	cee->attr_dma.pa = dma_pa;
	cee->stats_dma.kva = dma_kva + bfa_cee_attr_meminfo();
	cee->stats_dma.pa = dma_pa + bfa_cee_attr_meminfo();
	cee->attr = (struct bfa_cee_attr *) dma_kva;
	cee->stats = (struct bfa_cee_stats *)
		(dma_kva + bfa_cee_attr_meminfo());
}

/**
 * bfa_cee_get_attr()
 *
 * @brief
 *   Send the request to the f/w to fetch CEE attributes.
 *
 * @param[in] Pointer to the CEE module data structure.
 *
 * @return Status
 */

enum bfa_status
bfa_cee_get_attr(struct bfa_cee *cee, struct bfa_cee_attr *attr,
		     bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
{
	struct bfi_cee_get_req *cmd;

	BUG_ON(!((cee != NULL) && (cee->ioc != NULL)));
	if (!bfa_ioc_is_operational(cee->ioc))
		return BFA_STATUS_IOC_FAILURE;
	if (cee->get_attr_pending == true)
		return 	BFA_STATUS_DEVBUSY;
	cee->get_attr_pending = true;
	cmd = (struct bfi_cee_get_req *) cee->get_cfg_mb.msg;
	cee->attr = attr;
	cee->cbfn.get_attr_cbfn = cbfn;
	cee->cbfn.get_attr_cbarg = cbarg;
	bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
	    bfa_ioc_portid(cee->ioc));
	bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
	bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);

	return BFA_STATUS_OK;
}

/**
 * bfa_cee_get_stats()
 *
 * @brief
 *   Send the request to the f/w to fetch CEE statistics.
 *
 * @param[in] Pointer to the CEE module data structure.
 *
 * @return Status
 */

enum bfa_status
bfa_cee_get_stats(struct bfa_cee *cee, struct bfa_cee_stats *stats,
		      bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
{
	struct bfi_cee_get_req *cmd;

	BUG_ON(!((cee != NULL) && (cee->ioc != NULL)));

	if (!bfa_ioc_is_operational(cee->ioc))
		return BFA_STATUS_IOC_FAILURE;
	if (cee->get_stats_pending == true)
		return 	BFA_STATUS_DEVBUSY;
	cee->get_stats_pending = true;
	cmd = (struct bfi_cee_get_req *) cee->get_stats_mb.msg;
	cee->stats = stats;
	cee->cbfn.get_stats_cbfn = cbfn;
	cee->cbfn.get_stats_cbarg = cbarg;
	bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
	    bfa_ioc_portid(cee->ioc));
	bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
	bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);

	return BFA_STATUS_OK;
}

/**
 * bfa_cee_reset_stats()
 *
 * @brief Clears CEE Stats in the f/w.
 *
 * @param[in] Pointer to the CEE module data structure.
 *
 * @return Status
 */

enum bfa_status
bfa_cee_reset_stats(struct bfa_cee *cee, bfa_cee_reset_stats_cbfn_t cbfn,
			void *cbarg)
{
	struct bfi_cee_reset_stats *cmd;

	BUG_ON(!((cee != NULL) && (cee->ioc != NULL)));
	if (!bfa_ioc_is_operational(cee->ioc))
		return BFA_STATUS_IOC_FAILURE;
	if (cee->reset_stats_pending == true)
		return 	BFA_STATUS_DEVBUSY;
	cee->reset_stats_pending = true;
	cmd = (struct bfi_cee_reset_stats *) cee->reset_stats_mb.msg;
	cee->cbfn.reset_stats_cbfn = cbfn;
	cee->cbfn.reset_stats_cbarg = cbarg;
	bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
	    bfa_ioc_portid(cee->ioc));
	bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
	return BFA_STATUS_OK;
}

/**
 * bfa_cee_isrs()
 *
 * @brief Handles Mail-box interrupts for CEE module.
 *
 * @param[in] Pointer to the CEE module data structure.
 *
 * @return void
 */

void
bfa_cee_isr(void *cbarg, struct bfi_mbmsg *m)
{
	union bfi_cee_i2h_msg_u *msg;
	struct bfi_cee_get_rsp *get_rsp;
	struct bfa_cee *cee = (struct bfa_cee *) cbarg;
	msg = (union bfi_cee_i2h_msg_u *) m;
	get_rsp = (struct bfi_cee_get_rsp *) m;
	switch (msg->mh.msg_id) {
	case BFI_CEE_I2H_GET_CFG_RSP:
		bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
		break;
	case BFI_CEE_I2H_GET_STATS_RSP:
		bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
		break;
	case BFI_CEE_I2H_RESET_STATS_RSP:
		bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
		break;
	default:
		BUG_ON(1);
	}
}

/**
 * bfa_cee_hbfail()
 *
 * @brief CEE module heart-beat failure handler.
 *
 * @param[in] Pointer to the CEE module data structure.
 *
 * @return void
 */

void
bfa_cee_hbfail(void *arg)
{
	struct bfa_cee *cee;
	cee = (struct bfa_cee *) arg;

	if (cee->get_attr_pending == true) {
		cee->get_attr_status = BFA_STATUS_FAILED;
		cee->get_attr_pending  = false;
		if (cee->cbfn.get_attr_cbfn) {
			cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg,
			    BFA_STATUS_FAILED);
		}
	}
	if (cee->get_stats_pending == true) {
		cee->get_stats_status = BFA_STATUS_FAILED;
		cee->get_stats_pending  = false;
		if (cee->cbfn.get_stats_cbfn) {
			cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg,
			    BFA_STATUS_FAILED);
		}
	}
	if (cee->reset_stats_pending == true) {
		cee->reset_stats_status = BFA_STATUS_FAILED;
		cee->reset_stats_pending  = false;
		if (cee->cbfn.reset_stats_cbfn) {
			cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg,
			    BFA_STATUS_FAILED);
		}
	}
}

/**
 * bfa_cee_attach()
 *
 * @brief CEE module-attach API
 *
 * @param[in] cee - Pointer to the CEE module data structure
 *            ioc - Pointer to the ioc module data structure
 *            dev - Pointer to the device driver module data structure
 *                  The device driver specific mbox ISR functions have
 *                  this pointer as one of the parameters.
 *
 * @return void
 */
void
bfa_cee_attach(struct bfa_cee *cee, struct bfa_ioc *ioc,
		void *dev)
{
	BUG_ON(!(cee != NULL));
	cee->dev = dev;
	cee->ioc = ioc;

	bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
	bfa_ioc_hbfail_init(&cee->hbfail, bfa_cee_hbfail, cee);
	bfa_ioc_hbfail_register(cee->ioc, &cee->hbfail);
}

/**
 * bfa_cee_detach()
 *
 * @brief CEE module-detach API
 *
 * @param[in] cee - Pointer to the CEE module data structure
 *
 * @return void
 */
void
bfa_cee_detach(struct bfa_cee *cee)
{
}
Loading