From patchwork Fri Aug 19 09:50:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9289917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3BB5607FF for ; Fri, 19 Aug 2016 09:51:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D40F8292FF for ; Fri, 19 Aug 2016 09:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8E4A29333; Fri, 19 Aug 2016 09:51:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38FDF292FF for ; Fri, 19 Aug 2016 09:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752848AbcHSJvQ (ORCPT ); Fri, 19 Aug 2016 05:51:16 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37681 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585AbcHSJvK (ORCPT ); Fri, 19 Aug 2016 05:51:10 -0400 Received: by mail-wm0-f48.google.com with SMTP id i5so32723463wmg.0 for ; Fri, 19 Aug 2016 02:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o1LN2MIXQbaBytTXuUV5WIkHxBn/BXcNReQZzLr+Moo=; b=H0a4efyzrFug9652tA+Jc1QrD6+Loovfl+ReaawioSh9DVACjdQ4YF6mNFm/lDC3OI KYUMkwAXyvvQ39mv82BwXPs2uBfxEfxeBZtmu12yP93XdmVOV8jjHNtagsdKD1k7ubsG HckVkgn600ka3yqhwhx9ncVYz3ClCh4CGOIos= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o1LN2MIXQbaBytTXuUV5WIkHxBn/BXcNReQZzLr+Moo=; b=bZgEYGOD//9pkKFvo2CHc54C1Zu7l6qTnPL77uhJh1KvYTrU0GcuFLmX4wpHLvzZfT mfJ3NmJaVuQZt1fnS5MP4QjyKLLzgHO3i2XR1xpjP6C7oGGqCnskuIHVzkeQqAo6FG4P nS2as218F6JzcOjFCkDyVbzCfVrNpgcZH8Z8vM4pKpTFyJkXesgNrrjDNYNzgbHIB7A3 O7BPIPBGYbrCTFot0myxkgPsB5VeWeFNlLFwh+vuDsG5kIBm0HGgh7/zfaWNQiOrMHj5 PpSnz18SdWE+xRY2l2Qfi6mw8KTlEX9YnupA86ELUf2tvwde4Gu1WDiLqXb79mqU8REr JHCw== X-Gm-Message-State: AEkoouuPioPgKTikQvGhTxbA9L8avkUSuSau5lZnNPvlc7Bh2w/BSXokvyLBAfq6+fW6Iubc X-Received: by 10.194.27.133 with SMTP id t5mr5662187wjg.15.1471600259688; Fri, 19 Aug 2016 02:50:59 -0700 (PDT) Received: from android.dhcp.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id n131sm3650096wmd.3.2016.08.19.02.50.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Aug 2016 02:50:58 -0700 (PDT) From: Jitendra Bhivare To: linux-scsi@vger.kernel.org Cc: mchristi@redhat.com, Jitendra Bhivare Subject: [PATCH v2 05/29] be2iscsi: Fix gateway APIs to support IPv4 & IPv6 Date: Fri, 19 Aug 2016 15:20:02 +0530 Message-Id: <1471600226-22055-6-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471600226-22055-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1471600226-22055-1-git-send-email-jitendra.bhivare@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Gateway APIs assume IP type as IPv4. Modify it to be generic to allow clearing of IPv6 gateway set using BIOS. Signed-off-by: Jitendra Bhivare Reviewed-by: Hannes Reinecke --- drivers/scsi/be2iscsi/be_iscsi.c | 4 +- drivers/scsi/be2iscsi/be_mgmt.c | 124 ++++++++++++++++++--------------------- drivers/scsi/be2iscsi/be_mgmt.h | 7 +-- 3 files changed, 62 insertions(+), 73 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index eab0f4f..3ebfeff 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -419,7 +419,7 @@ beiscsi_set_ipv4(struct Scsi_Host *shost, } break; case ISCSI_NET_PARAM_IPV4_GW: - ret = mgmt_set_gateway(phba, iface_param); + ret = beiscsi_if_set_gw(phba, BE2_IPV4, iface_param->value); break; case ISCSI_NET_PARAM_IPV4_BOOTPROTO: if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP) @@ -635,7 +635,7 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface, break; case ISCSI_NET_PARAM_IPV4_GW: memset(&gateway, 0, sizeof(gateway)); - len = mgmt_get_gateway(phba, BE2_IPV4, &gateway); + len = beiscsi_if_get_gw(phba, BE2_IPV4, &gateway); if (!len) len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); break; diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 83926e2..9ef9f76 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -1059,14 +1059,13 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba, return rc; } -static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, - uint32_t gtway_action, uint32_t param_len) +static int beiscsi_if_mod_gw(struct beiscsi_hba *phba, + u32 action, u32 ip_type, u8 *gw) { struct be_cmd_set_def_gateway_req *req; struct be_dma_mem nonemb_cmd; int rt_val; - rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd, OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, sizeof(*req)); @@ -1074,12 +1073,60 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, return rt_val; req = nonemb_cmd.va; - req->action = gtway_action; - req->ip_addr.ip_type = BE2_IPV4; + req->action = action; + req->ip_addr.ip_type = ip_type; + memcpy(req->ip_addr.addr, gw, + (ip_type == BE2_IPV4) ? IP_V4_LEN : IP_V6_LEN); + return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); +} - memcpy(req->ip_addr.addr, gt_addr, sizeof(req->ip_addr.addr)); +int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw) +{ + struct be_cmd_get_def_gateway_resp gw_resp; + int rt_val; - return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); + memset(&gw_resp, 0, sizeof(gw_resp)); + rt_val = beiscsi_if_get_gw(phba, ip_type, &gw_resp); + if (rt_val) { + beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, + "BG_%d : Failed to Get Gateway Addr\n"); + return rt_val; + } + + rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, ip_type, + gw_resp.ip_addr.addr); + if (rt_val) { + beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, + "BG_%d : Failed to clear Gateway Addr Set\n"); + return rt_val; + } + + rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_ADD, ip_type, gw); + if (rt_val) + beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, + "BG_%d : Failed to Set Gateway Addr\n"); + + return rt_val; +} + +int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, + struct be_cmd_get_def_gateway_resp *resp) +{ + struct be_cmd_get_def_gateway_req *req; + struct be_dma_mem nonemb_cmd; + int rc; + + rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, + OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, + sizeof(*resp)); + if (rc) + return rc; + + req = nonemb_cmd.va; + req->ip_type = ip_type; + + return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, resp, + sizeof(*resp)); } int mgmt_set_ip(struct beiscsi_hba *phba, @@ -1156,7 +1203,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba, /* Delete the Gateway settings if mode change is to DHCP */ if (boot_proto == ISCSI_BOOTPROTO_DHCP) { memset(>way_addr_set, 0, sizeof(gtway_addr_set)); - rc = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); + rc = beiscsi_if_get_gw(phba, BE2_IPV4, >way_addr_set); if (rc) { beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, "BG_%d : Failed to Get Gateway Addr\n"); @@ -1165,8 +1212,8 @@ int mgmt_set_ip(struct beiscsi_hba *phba, if (gtway_addr_set.ip_addr.addr[0]) { gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; - rc = mgmt_modify_gateway(phba, gtway_addr, - IP_ACTION_DEL, IP_V4_LEN); + rc = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, + ip_type, gtway_addr); if (rc) { beiscsi_log(phba, KERN_WARNING, @@ -1202,63 +1249,6 @@ exit: return rc; } -int mgmt_set_gateway(struct beiscsi_hba *phba, - struct iscsi_iface_param_info *gateway_param) -{ - struct be_cmd_get_def_gateway_resp gtway_addr_set; - uint8_t *gtway_addr; - int rt_val; - - memset(>way_addr_set, 0, sizeof(gtway_addr_set)); - rt_val = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); - if (rt_val) { - beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, - "BG_%d : Failed to Get Gateway Addr\n"); - return rt_val; - } - - if (gtway_addr_set.ip_addr.addr[0]) { - gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; - rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_DEL, - gateway_param->len); - if (rt_val) { - beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, - "BG_%d : Failed to clear Gateway Addr Set\n"); - return rt_val; - } - } - - gtway_addr = (uint8_t *)&gateway_param->value; - rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_ADD, - gateway_param->len); - - if (rt_val) - beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, - "BG_%d : Failed to Set Gateway Addr\n"); - - return rt_val; -} - -int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, - struct be_cmd_get_def_gateway_resp *gateway) -{ - struct be_cmd_get_def_gateway_req *req; - struct be_dma_mem nonemb_cmd; - int rc; - - rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, - OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, - sizeof(*gateway)); - if (rc) - return rc; - - req = nonemb_cmd.va; - req->ip_type = ip_type; - - return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, gateway, - sizeof(*gateway)); -} - int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, struct be_cmd_get_if_info_resp **if_info) { diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index f3a48a0..fd9b68f 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h @@ -298,11 +298,10 @@ int mgmt_get_nic_conf(struct beiscsi_hba *phba, 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 beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, + struct be_cmd_get_def_gateway_resp *resp); -int mgmt_set_gateway(struct beiscsi_hba *phba, - struct iscsi_iface_param_info *gateway_param); +int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw); int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, unsigned int *s_handle);