Commit aea71a02 authored by Bhanu Prakash Gollapudi's avatar Bhanu Prakash Gollapudi Committed by James Bottomley
Browse files

[SCSI] bnx2fc: Introduce interface structure for each vlan interface



Currently, bnx2fc has a hba structure that can work with only a single vlan
interface.  When there is a change in vlan id, it does not have the capability
to switch to different vlan interface. To solve this problem, a new structure
called 'interface' has been introduced, and each hba can now have multiple
interfaces, one per vlan id.

Most of the patch is a moving the interface specific fields from hba to the
interface structure, and appropriately modifying the dereferences. A list of
interfaces (if_list) is maintained along with adapter list. During a create
call, the interface structure is allocated and added to if_list and deleted &
freed on a destroy call.  Link events are propagated to all interfaces
belonging to the hba.

Signed-off-by: default avatarBhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent f6e76055
Loading
Loading
Loading
Loading
+31 −43
Original line number Diff line number Diff line
@@ -153,18 +153,13 @@ struct bnx2fc_percpu_s {
};

struct bnx2fc_hba {
	struct list_head link;
	struct list_head list;
	struct cnic_dev *cnic;
	struct pci_dev *pcidev;
	struct net_device *netdev;
	struct net_device *phys_dev;
	unsigned long reg_with_cnic;
		#define BNX2FC_CNIC_REGISTERED           1
	struct packet_type fcoe_packet_type;
	struct packet_type fip_packet_type;
	struct bnx2fc_cmd_mgr *cmd_mgr;
	struct workqueue_struct *timer_work_queue;
	struct kref kref;
	spinlock_t hba_lock;
	struct mutex hba_mutex;
	unsigned long adapter_state;
@@ -172,15 +167,9 @@ struct bnx2fc_hba {
		#define ADAPTER_STATE_GOING_DOWN	1
		#define ADAPTER_STATE_LINK_DOWN		2
		#define ADAPTER_STATE_READY		3
	u32 flags;
	unsigned long init_done;
		#define BNX2FC_FW_INIT_DONE		0
		#define BNX2FC_CTLR_INIT_DONE		1
		#define BNX2FC_CREATE_DONE		2
	struct fcoe_ctlr ctlr;
	struct list_head vports;
	u8 vlan_enabled;
	int vlan_id;
	unsigned long flags;
		#define BNX2FC_FLAG_FW_INIT_DONE	0
		#define BNX2FC_FLAG_DESTROY_CMPL	1
	u32 next_conn_id;
	struct fcoe_task_ctx_entry **task_ctx;
	dma_addr_t *task_ctx_dma;
@@ -199,38 +188,41 @@ struct bnx2fc_hba {
	char *dummy_buffer;
	dma_addr_t dummy_buf_dma;

	/* Active list of offloaded sessions */
	struct bnx2fc_rport **tgt_ofld_list;

	/* statistics */
	struct fcoe_statistics_params *stats_buffer;
	dma_addr_t stats_buf_dma;

	/*
	 * PCI related info.
	 */
	u16 pci_did;
	u16 pci_vid;
	u16 pci_sdid;
	u16 pci_svid;
	u16 pci_func;
	u16 pci_devno;

	struct task_struct *l2_thread;

	/* linkdown handling */
	wait_queue_head_t shutdown_wait;
	int wait_for_link_down;
	struct completion stat_req_done;

	/*destroy handling */
	struct timer_list destroy_timer;
	wait_queue_head_t destroy_wait;

	/* Active list of offloaded sessions */
	struct bnx2fc_rport *tgt_ofld_list[BNX2FC_NUM_MAX_SESS];
	/* linkdown handling */
	wait_queue_head_t shutdown_wait;
	int wait_for_link_down;
	int num_ofld_sess;
	struct list_head vports;
};

	/* statistics */
	struct completion stat_req_done;
struct bnx2fc_interface {
	struct list_head list;
	unsigned long if_flags;
		#define BNX2FC_CTLR_INIT_DONE		0
	struct bnx2fc_hba *hba;
	struct net_device *netdev;
	struct packet_type fcoe_packet_type;
	struct packet_type fip_packet_type;
	struct workqueue_struct *timer_work_queue;
	struct kref kref;
	struct fcoe_ctlr ctlr;
	u8 vlan_enabled;
	int vlan_id;
};

#define bnx2fc_from_ctlr(fip) container_of(fip, struct bnx2fc_hba, ctlr)
#define bnx2fc_from_ctlr(fip) container_of(fip, struct bnx2fc_interface, ctlr)

struct bnx2fc_lport {
	struct list_head list;
@@ -262,10 +254,9 @@ struct bnx2fc_rport {
#define BNX2FC_FLAG_DISABLED		0x3
#define BNX2FC_FLAG_DESTROYED		0x4
#define BNX2FC_FLAG_OFLD_REQ_CMPL	0x5
#define BNX2FC_FLAG_DESTROY_CMPL	0x6
#define BNX2FC_FLAG_CTX_ALLOC_FAILURE	0x7
#define BNX2FC_FLAG_UPLD_REQ_COMPL	0x8
#define BNX2FC_FLAG_EXPL_LOGO		0x9
#define BNX2FC_FLAG_CTX_ALLOC_FAILURE	0x6
#define BNX2FC_FLAG_UPLD_REQ_COMPL	0x7
#define BNX2FC_FLAG_EXPL_LOGO		0x8

	u8 src_addr[ETH_ALEN];
	u32 max_sqes;
@@ -327,12 +318,9 @@ struct bnx2fc_rport {
	spinlock_t cq_lock;
	atomic_t num_active_ios;
	u32 flush_in_prog;
	unsigned long work_time_slice;
	unsigned long timestamp;
	struct list_head free_task_list;
	struct bnx2fc_cmd *pending_queue[BNX2FC_SQ_WQES_MAX+1];
	atomic_t pi;
	atomic_t ci;
	struct list_head active_cmd_queue;
	struct list_head els_queue;
	struct list_head io_retire_queue;
+5 −4
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ static int bnx2fc_initiate_els(struct bnx2fc_rport *tgt, unsigned int op,
			struct bnx2fc_els_cb_arg *cb_arg, u32 timer_msec)
{
	struct fcoe_port *port = tgt->port;
	struct bnx2fc_hba *hba = port->priv;
	struct bnx2fc_interface *interface = port->priv;
	struct fc_rport *rport = tgt->rport;
	struct fc_lport *lport = port->lport;
	struct bnx2fc_cmd *els_req;
@@ -352,7 +352,8 @@ static int bnx2fc_initiate_els(struct bnx2fc_rport *tgt, unsigned int op,
	index = xid % BNX2FC_TASKS_PER_PAGE;

	/* Initialize task context for this IO request */
	task_page = (struct fcoe_task_ctx_entry *) hba->task_ctx[task_idx];
	task_page = (struct fcoe_task_ctx_entry *)
			interface->hba->task_ctx[task_idx];
	task = &(task_page[index]);
	bnx2fc_init_mp_task(els_req, task);

@@ -496,8 +497,8 @@ struct fc_seq *bnx2fc_elsct_send(struct fc_lport *lport, u32 did,
				      void *arg, u32 timeout)
{
	struct fcoe_port *port = lport_priv(lport);
	struct bnx2fc_hba *hba = port->priv;
	struct fcoe_ctlr *fip = &hba->ctlr;
	struct bnx2fc_interface *interface = port->priv;
	struct fcoe_ctlr *fip = &interface->ctlr;
	struct fc_frame_header *fh = fc_frame_header_get(fp);

	switch (op) {
Loading