Commit 0e43895e authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] be2iscsi: adding functionality to change network settings using iscsiadm

This patch allows iscsiadm to set/ delete static IP and enable /disable
DHCP.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJayamohan Kallickal <jayamohan.kallickal@emulex.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent ffce3e2e
...@@ -163,7 +163,8 @@ struct be_mcc_mailbox { ...@@ -163,7 +163,8 @@ struct be_mcc_mailbox {
#define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
#define OPCODE_COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR 17 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
...@@ -274,15 +275,15 @@ struct mgmt_conn_login_options { ...@@ -274,15 +275,15 @@ struct mgmt_conn_login_options {
struct mgmt_auth_method_format auth_data; struct mgmt_auth_method_format auth_data;
} __packed; } __packed;
struct ip_address_format { struct ip_addr_format {
u16 size_of_structure; u16 size_of_structure;
u8 reserved; u8 reserved;
u8 ip_type; u8 ip_type;
u8 ip_address[16]; u8 addr[16];
u32 rsvd0; u32 rsvd0;
} __packed; } __packed;
struct mgmt_conn_info { struct mgmt_conn_info {
u32 connection_handle; u32 connection_handle;
u32 connection_status; u32 connection_status;
u16 src_port; u16 src_port;
...@@ -290,9 +291,9 @@ struct mgmt_conn_info { ...@@ -290,9 +291,9 @@ struct mgmt_conn_info {
u16 dest_port_redirected; u16 dest_port_redirected;
u16 cid; u16 cid;
u32 estimated_throughput; u32 estimated_throughput;
struct ip_address_format src_ipaddr; struct ip_addr_format src_ipaddr;
struct ip_address_format dest_ipaddr; struct ip_addr_format dest_ipaddr;
struct ip_address_format dest_ipaddr_redirected; struct ip_addr_format dest_ipaddr_redirected;
struct mgmt_conn_login_options negotiated_login_options; struct mgmt_conn_login_options negotiated_login_options;
} __packed; } __packed;
...@@ -322,43 +323,115 @@ struct mgmt_session_info { ...@@ -322,43 +323,115 @@ struct mgmt_session_info {
struct mgmt_conn_info conn_list[1]; struct mgmt_conn_info conn_list[1];
} __packed; } __packed;
struct be_cmd_req_get_session { struct be_cmd_get_session_req {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u32 session_handle; u32 session_handle;
} __packed; } __packed;
struct be_cmd_resp_get_session { struct be_cmd_get_session_resp {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
struct mgmt_session_info session_info; struct mgmt_session_info session_info;
} __packed; } __packed;
struct mac_addr { struct mac_addr {
u16 size_of_struct; u16 size_of_structure;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
} __packed; } __packed;
struct be_cmd_req_get_boot_target { struct be_cmd_get_boot_target_req {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
} __packed; } __packed;
struct be_cmd_resp_get_boot_target { struct be_cmd_get_boot_target_resp {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
u32 boot_session_count; u32 boot_session_count;
int boot_session_handle; int boot_session_handle;
}; };
struct be_cmd_req_mac_query { struct be_cmd_mac_query_req {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u8 type; u8 type;
u8 permanent; u8 permanent;
u16 if_id; u16 if_id;
} __packed; } __packed;
struct be_cmd_resp_mac_query { struct be_cmd_get_mac_resp {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
struct mac_addr mac; struct mac_addr mac;
}; };
struct be_ip_addr_subnet_format {
u16 size_of_structure;
u8 ip_type;
u8 ipv6_prefix_length;
u8 addr[16];
u8 subnet_mask[16];
u32 rsvd0;
} __packed;
struct be_cmd_get_if_info_req {
struct be_cmd_req_hdr hdr;
u32 interface_hndl;
u32 ip_type;
} __packed;
struct be_cmd_get_if_info_resp {
struct be_cmd_req_hdr hdr;
u32 interface_hndl;
u32 vlan_priority;
u32 ip_addr_count;
u32 dhcp_state;
struct be_ip_addr_subnet_format ip_addr;
} __packed;
struct be_ip_addr_record {
u32 action;
u32 interface_hndl;
struct be_ip_addr_subnet_format ip_addr;
u32 status;
} __packed;
struct be_ip_addr_record_params {
u32 record_entry_count;
struct be_ip_addr_record ip_record;
} __packed;
struct be_cmd_set_ip_addr_req {
struct be_cmd_req_hdr hdr;
struct be_ip_addr_record_params ip_params;
} __packed;
struct be_cmd_set_dhcp_req {
struct be_cmd_req_hdr hdr;
u32 interface_hndl;
u32 ip_type;
u32 flags;
u32 retry_count;
} __packed;
struct be_cmd_rel_dhcp_req {
struct be_cmd_req_hdr hdr;
u32 interface_hndl;
u32 ip_type;
} __packed;
struct be_cmd_set_def_gateway_req {
struct be_cmd_req_hdr hdr;
u32 action;
struct ip_addr_format ip_addr;
} __packed;
struct be_cmd_get_def_gateway_req {
struct be_cmd_req_hdr hdr;
u32 ip_type;
} __packed;
struct be_cmd_get_def_gateway_resp {
struct be_cmd_req_hdr hdr;
struct ip_addr_format ip_addr;
} __packed;
/******************** Create CQ ***************************/ /******************** Create CQ ***************************/
/** /**
* Pseudo amap definition in which each bit of the actual structure is defined * Pseudo amap definition in which each bit of the actual structure is defined
...@@ -489,7 +562,7 @@ struct be_cmd_req_modify_eq_delay { ...@@ -489,7 +562,7 @@ struct be_cmd_req_modify_eq_delay {
#define ETH_ALEN 6 #define ETH_ALEN 6
struct be_cmd_req_get_mac_addr { struct be_cmd_get_nic_conf_req {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u32 nic_port_count; u32 nic_port_count;
u32 speed; u32 speed;
...@@ -501,7 +574,7 @@ struct be_cmd_req_get_mac_addr { ...@@ -501,7 +574,7 @@ struct be_cmd_req_get_mac_addr {
u32 rsvd[23]; u32 rsvd[23];
}; };
struct be_cmd_resp_get_mac_addr { struct be_cmd_get_nic_conf_resp {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
u32 nic_port_count; u32 nic_port_count;
u32 speed; u32 speed;
...@@ -541,12 +614,7 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba, ...@@ -541,12 +614,7 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
int be_poll_mcc(struct be_ctrl_info *ctrl); int be_poll_mcc(struct be_ctrl_info *ctrl);
int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
struct beiscsi_hba *phba); struct beiscsi_hba *phba);
unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba);
unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba);
unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba,
u32 boot_session_handle,
struct be_dma_mem *nonemb_cmd);
void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
/*ISCSI Functuions */ /*ISCSI Functuions */
...@@ -727,7 +795,7 @@ struct be_eq_delay_params_in { ...@@ -727,7 +795,7 @@ struct be_eq_delay_params_in {
struct tcp_connect_and_offload_in { struct tcp_connect_and_offload_in {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
struct ip_address_format ip_address; struct ip_addr_format ip_address;
u16 tcp_port; u16 tcp_port;
u16 cid; u16 cid;
u16 cq_id; u16 cq_id;
...@@ -804,7 +872,7 @@ struct be_fw_cfg { ...@@ -804,7 +872,7 @@ struct be_fw_cfg {
u32 function_caps; u32 function_caps;
} __packed; } __packed;
struct be_all_if_id { struct be_cmd_get_all_if_id_req {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u32 if_count; u32 if_count;
u32 if_hndl_list[1]; u32 if_hndl_list[1];
......
This diff is collapsed.
...@@ -25,6 +25,21 @@ ...@@ -25,6 +25,21 @@
#define BE2_IPV4 0x1 #define BE2_IPV4 0x1
#define BE2_IPV6 0x10 #define BE2_IPV6 0x10
#define BE2_DHCP_V4 0x05
#define NON_BLOCKING 0x0
#define BLOCKING 0x1
void beiscsi_create_def_ifaces(struct beiscsi_hba *phba);
void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba);
int be2iscsi_iface_get_param(struct iscsi_iface *iface,
enum iscsi_param_type param_type,
int param, char *buf);
int be2iscsi_iface_set_param(struct Scsi_Host *shost,
void *data, uint32_t count);
umode_t be2iscsi_attr_is_visible(int param_type, int param); umode_t be2iscsi_attr_is_visible(int param_type, int param);
......
...@@ -231,10 +231,10 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) ...@@ -231,10 +231,10 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf)
case ISCSI_BOOT_TGT_IP_ADDR: case ISCSI_BOOT_TGT_IP_ADDR:
if (boot_conn->dest_ipaddr.ip_type == 0x1) if (boot_conn->dest_ipaddr.ip_type == 0x1)
rc = sprintf(buf, "%pI4\n", rc = sprintf(buf, "%pI4\n",
(char *)&boot_conn->dest_ipaddr.ip_address); (char *)&boot_conn->dest_ipaddr.addr);
else else
rc = sprintf(str, "%pI6\n", rc = sprintf(str, "%pI6\n",
(char *)&boot_conn->dest_ipaddr.ip_address); (char *)&boot_conn->dest_ipaddr.addr);
break; break;
case ISCSI_BOOT_TGT_PORT: case ISCSI_BOOT_TGT_PORT:
rc = sprintf(str, "%d\n", boot_conn->dest_port); rc = sprintf(str, "%d\n", boot_conn->dest_port);
...@@ -312,12 +312,8 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) ...@@ -312,12 +312,8 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf)
rc = sprintf(str, "0\n"); rc = sprintf(str, "0\n");
break; break;
case ISCSI_BOOT_ETH_MAC: case ISCSI_BOOT_ETH_MAC:
rc = beiscsi_get_macaddr(buf, phba); rc = beiscsi_get_macaddr(str, phba);
if (rc < 0) { break;
SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n");
return rc;
}
break;
default: default:
rc = -ENOSYS; rc = -ENOSYS;
break; break;
...@@ -438,6 +434,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) ...@@ -438,6 +434,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev)
phba->shost = shost; phba->shost = shost;
phba->pcidev = pci_dev_get(pcidev); phba->pcidev = pci_dev_get(pcidev);
pci_set_drvdata(pcidev, phba); pci_set_drvdata(pcidev, phba);
phba->interface_handle = 0xFFFFFFFF;
if (iscsi_host_add(shost, &phba->pcidev->dev)) if (iscsi_host_add(shost, &phba->pcidev->dev))
goto free_devices; goto free_devices;
...@@ -3471,8 +3468,8 @@ static void hwi_disable_intr(struct beiscsi_hba *phba) ...@@ -3471,8 +3468,8 @@ static void hwi_disable_intr(struct beiscsi_hba *phba)
static int beiscsi_get_boot_info(struct beiscsi_hba *phba) static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
{ {
struct be_cmd_resp_get_boot_target *boot_resp; struct be_cmd_get_boot_target_resp *boot_resp;
struct be_cmd_resp_get_session *session_resp; struct be_cmd_get_session_resp *session_resp;
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_dma_mem nonemb_cmd; struct be_dma_mem nonemb_cmd;
unsigned int tag, wrb_num; unsigned int tag, wrb_num;
...@@ -3480,9 +3477,9 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba) ...@@ -3480,9 +3477,9 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
int ret = -ENOMEM; int ret = -ENOMEM;
tag = beiscsi_get_boot_target(phba); tag = mgmt_get_boot_target(phba);
if (!tag) { if (!tag) {
SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n"); SE_DEBUG(DBG_LVL_1, "beiscsi_get_boot_info Failed\n");
return -EAGAIN; return -EAGAIN;
} else } else
wait_event_interruptible(phba->ctrl.mcc_wait[tag], wait_event_interruptible(phba->ctrl.mcc_wait[tag],
...@@ -3492,7 +3489,7 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba) ...@@ -3492,7 +3489,7 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
if (status || extd_status) { if (status || extd_status) {
SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed" SE_DEBUG(DBG_LVL_1, "beiscsi_get_boot_info Failed"
" status = %d extd_status = %d\n", " status = %d extd_status = %d\n",
status, extd_status); status, extd_status);
free_mcc_tag(&phba->ctrl, tag); free_mcc_tag(&phba->ctrl, tag);
...@@ -3518,8 +3515,8 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba) ...@@ -3518,8 +3515,8 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
} }
memset(nonemb_cmd.va, 0, sizeof(*session_resp)); memset(nonemb_cmd.va, 0, sizeof(*session_resp));
tag = beiscsi_get_session_info(phba, tag = mgmt_get_session_info(phba, boot_resp->boot_session_handle,
boot_resp->boot_session_handle, &nonemb_cmd); &nonemb_cmd);
if (!tag) { if (!tag) {
SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info" SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info"
" Failed\n"); " Failed\n");
...@@ -4267,6 +4264,7 @@ static void beiscsi_remove(struct pci_dev *pcidev) ...@@ -4267,6 +4264,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
return; return;
} }
beiscsi_destroy_def_ifaces(phba);
beiscsi_quiesce(phba); beiscsi_quiesce(phba);
iscsi_boot_destroy_kset(phba->boot_kset); iscsi_boot_destroy_kset(phba->boot_kset);
iscsi_host_remove(phba->shost); iscsi_host_remove(phba->shost);
...@@ -4453,8 +4451,9 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -4453,8 +4451,9 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
* iscsi boot. * iscsi boot.
*/ */
shost_printk(KERN_ERR, phba->shost, "Could not set up " shost_printk(KERN_ERR, phba->shost, "Could not set up "
"iSCSI boot info."); "iSCSI boot info.\n");
beiscsi_create_def_ifaces(phba);
SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED\n\n\n"); SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED\n\n\n");
return 0; return 0;
...@@ -4505,6 +4504,8 @@ struct iscsi_transport beiscsi_iscsi_transport = { ...@@ -4505,6 +4504,8 @@ struct iscsi_transport beiscsi_iscsi_transport = {
.bind_conn = beiscsi_conn_bind, .bind_conn = beiscsi_conn_bind,
.destroy_conn = iscsi_conn_teardown, .destroy_conn = iscsi_conn_teardown,
.attr_is_visible = be2iscsi_attr_is_visible, .attr_is_visible = be2iscsi_attr_is_visible,
.set_iface_param = be2iscsi_iface_set_param,
.get_iface_param = be2iscsi_iface_get_param,
.set_param = beiscsi_set_param, .set_param = beiscsi_set_param,
.get_conn_param = iscsi_conn_get_param, .get_conn_param = iscsi_conn_get_param,
.get_session_param = iscsi_session_get_param, .get_session_param = iscsi_session_get_param,
......
...@@ -316,6 +316,8 @@ struct beiscsi_hba { ...@@ -316,6 +316,8 @@ struct beiscsi_hba {
struct iscsi_endpoint **ep_array; struct iscsi_endpoint **ep_array;
struct iscsi_boot_kset *boot_kset; struct iscsi_boot_kset *boot_kset;
struct Scsi_Host *shost; struct Scsi_Host *shost;
struct iscsi_iface *ipv4_iface;
struct iscsi_iface *ipv6_iface;
struct { struct {
/** /**
* group together since they are used most frequently * group together since they are used most frequently
...@@ -345,7 +347,7 @@ struct beiscsi_hba { ...@@ -345,7 +347,7 @@ struct beiscsi_hba {
struct work_struct work_cqs; /* The work being queued */ struct work_struct work_cqs; /* The work being queued */
struct be_ctrl_info ctrl; struct be_ctrl_info ctrl;
unsigned int generation; unsigned int generation;
unsigned int read_mac_address; unsigned int interface_handle;
struct mgmt_session_info boot_sess; struct mgmt_session_info boot_sess;
struct invalidate_command_table inv_tbl[128]; struct invalidate_command_table inv_tbl[128];
......
This diff is collapsed.
...@@ -20,12 +20,16 @@ ...@@ -20,12 +20,16 @@
#ifndef _BEISCSI_MGMT_ #ifndef _BEISCSI_MGMT_
#define _BEISCSI_MGMT_ #define _BEISCSI_MGMT_
#include <linux/types.h>
#include <linux/list.h>
#include <scsi/scsi_bsg_iscsi.h> #include <scsi/scsi_bsg_iscsi.h>
#include "be_iscsi.h" #include "be_iscsi.h"
#include "be_main.h" #include "be_main.h"
#define IP_ACTION_ADD 0x01
#define IP_ACTION_DEL 0x02
#define IP_V6_LEN 16
#define IP_V4_LEN 4
/** /**
* Pseudo amap definition in which each bit of the actual structure is defined * Pseudo amap definition in which each bit of the actual structure is defined
* as a byte: used to calculate offset/shift/mask of each field * as a byte: used to calculate offset/shift/mask of each field
...@@ -263,4 +267,27 @@ unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, ...@@ -263,4 +267,27 @@ unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
unsigned short issue_reset, unsigned short issue_reset,
unsigned short savecfg_flag); unsigned short savecfg_flag);
int mgmt_set_ip(struct beiscsi_hba *phba,
struct iscsi_iface_param_info *ip_param,
struct iscsi_iface_param_info *subnet_param,
uint32_t boot_proto);
unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba);
unsigned int mgmt_get_session_info(struct beiscsi_hba *phba,
u32 boot_session_handle,
struct be_dma_mem *nonemb_cmd);
int mgmt_get_nic_conf(struct beiscsi_hba *phba,
struct be_cmd_get_nic_conf_resp *mac);
int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
struct be_cmd_get_if_info_resp *if_info);
int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type,
struct be_cmd_get_def_gateway_resp *gateway);
int mgmt_set_gateway(struct beiscsi_hba *phba,
struct iscsi_iface_param_info *gateway_param);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment