diff options
Diffstat (limited to 'drivers/scsi/bfa/bfad_bsg.c')
-rw-r--r-- | drivers/scsi/bfa/bfad_bsg.c | 375 |
1 files changed, 330 insertions, 45 deletions
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 0afa39076cef..555e7db94a1c 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c | |||
@@ -33,7 +33,7 @@ bfad_iocmd_ioc_enable(struct bfad_s *bfad, void *cmd) | |||
33 | /* If IOC is not in disabled state - return */ | 33 | /* If IOC is not in disabled state - return */ |
34 | if (!bfa_ioc_is_disabled(&bfad->bfa.ioc)) { | 34 | if (!bfa_ioc_is_disabled(&bfad->bfa.ioc)) { |
35 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 35 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
36 | iocmd->status = BFA_STATUS_IOC_FAILURE; | 36 | iocmd->status = BFA_STATUS_OK; |
37 | return rc; | 37 | return rc; |
38 | } | 38 | } |
39 | 39 | ||
@@ -54,6 +54,12 @@ bfad_iocmd_ioc_disable(struct bfad_s *bfad, void *cmd) | |||
54 | unsigned long flags; | 54 | unsigned long flags; |
55 | 55 | ||
56 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 56 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
57 | if (bfa_ioc_is_disabled(&bfad->bfa.ioc)) { | ||
58 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
59 | iocmd->status = BFA_STATUS_OK; | ||
60 | return rc; | ||
61 | } | ||
62 | |||
57 | if (bfad->disable_active) { | 63 | if (bfad->disable_active) { |
58 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 64 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
59 | return -EBUSY; | 65 | return -EBUSY; |
@@ -101,9 +107,10 @@ bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd) | |||
101 | 107 | ||
102 | /* set adapter hw path */ | 108 | /* set adapter hw path */ |
103 | strcpy(iocmd->adapter_hwpath, bfad->pci_name); | 109 | strcpy(iocmd->adapter_hwpath, bfad->pci_name); |
104 | i = strlen(iocmd->adapter_hwpath) - 1; | 110 | for (i = 0; iocmd->adapter_hwpath[i] != ':' && i < BFA_STRING_32; i++) |
105 | while (iocmd->adapter_hwpath[i] != '.') | 111 | ; |
106 | i--; | 112 | for (; iocmd->adapter_hwpath[++i] != ':' && i < BFA_STRING_32; ) |
113 | ; | ||
107 | iocmd->adapter_hwpath[i] = '\0'; | 114 | iocmd->adapter_hwpath[i] = '\0'; |
108 | iocmd->status = BFA_STATUS_OK; | 115 | iocmd->status = BFA_STATUS_OK; |
109 | return 0; | 116 | return 0; |
@@ -880,6 +887,19 @@ out: | |||
880 | } | 887 | } |
881 | 888 | ||
882 | int | 889 | int |
890 | bfad_iocmd_qos_set_bw(struct bfad_s *bfad, void *pcmd) | ||
891 | { | ||
892 | struct bfa_bsg_qos_bw_s *iocmd = (struct bfa_bsg_qos_bw_s *)pcmd; | ||
893 | unsigned long flags; | ||
894 | |||
895 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
896 | iocmd->status = bfa_fcport_set_qos_bw(&bfad->bfa, &iocmd->qos_bw); | ||
897 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
898 | |||
899 | return 0; | ||
900 | } | ||
901 | |||
902 | int | ||
883 | bfad_iocmd_ratelim(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | 903 | bfad_iocmd_ratelim(struct bfad_s *bfad, unsigned int cmd, void *pcmd) |
884 | { | 904 | { |
885 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd; | 905 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd; |
@@ -888,16 +908,22 @@ bfad_iocmd_ratelim(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | |||
888 | 908 | ||
889 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 909 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
890 | 910 | ||
891 | if (cmd == IOCMD_RATELIM_ENABLE) | 911 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
892 | fcport->cfg.ratelimit = BFA_TRUE; | 912 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
893 | else if (cmd == IOCMD_RATELIM_DISABLE) | 913 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; |
894 | fcport->cfg.ratelimit = BFA_FALSE; | 914 | else { |
915 | if (cmd == IOCMD_RATELIM_ENABLE) | ||
916 | fcport->cfg.ratelimit = BFA_TRUE; | ||
917 | else if (cmd == IOCMD_RATELIM_DISABLE) | ||
918 | fcport->cfg.ratelimit = BFA_FALSE; | ||
895 | 919 | ||
896 | if (fcport->cfg.trl_def_speed == BFA_PORT_SPEED_UNKNOWN) | 920 | if (fcport->cfg.trl_def_speed == BFA_PORT_SPEED_UNKNOWN) |
897 | fcport->cfg.trl_def_speed = BFA_PORT_SPEED_1GBPS; | 921 | fcport->cfg.trl_def_speed = BFA_PORT_SPEED_1GBPS; |
922 | |||
923 | iocmd->status = BFA_STATUS_OK; | ||
924 | } | ||
898 | 925 | ||
899 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 926 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
900 | iocmd->status = BFA_STATUS_OK; | ||
901 | 927 | ||
902 | return 0; | 928 | return 0; |
903 | } | 929 | } |
@@ -919,8 +945,13 @@ bfad_iocmd_ratelim_speed(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | |||
919 | return 0; | 945 | return 0; |
920 | } | 946 | } |
921 | 947 | ||
922 | fcport->cfg.trl_def_speed = iocmd->speed; | 948 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
923 | iocmd->status = BFA_STATUS_OK; | 949 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
950 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; | ||
951 | else { | ||
952 | fcport->cfg.trl_def_speed = iocmd->speed; | ||
953 | iocmd->status = BFA_STATUS_OK; | ||
954 | } | ||
924 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 955 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
925 | 956 | ||
926 | return 0; | 957 | return 0; |
@@ -1167,8 +1198,8 @@ bfad_iocmd_pcifn_create(struct bfad_s *bfad, void *cmd) | |||
1167 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 1198 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
1168 | iocmd->status = bfa_ablk_pf_create(&bfad->bfa.modules.ablk, | 1199 | iocmd->status = bfa_ablk_pf_create(&bfad->bfa.modules.ablk, |
1169 | &iocmd->pcifn_id, iocmd->port, | 1200 | &iocmd->pcifn_id, iocmd->port, |
1170 | iocmd->pcifn_class, iocmd->bandwidth, | 1201 | iocmd->pcifn_class, iocmd->bw_min, |
1171 | bfad_hcb_comp, &fcomp); | 1202 | iocmd->bw_max, bfad_hcb_comp, &fcomp); |
1172 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 1203 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
1173 | if (iocmd->status != BFA_STATUS_OK) | 1204 | if (iocmd->status != BFA_STATUS_OK) |
1174 | goto out; | 1205 | goto out; |
@@ -1211,8 +1242,8 @@ bfad_iocmd_pcifn_bw(struct bfad_s *bfad, void *cmd) | |||
1211 | init_completion(&fcomp.comp); | 1242 | init_completion(&fcomp.comp); |
1212 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 1243 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
1213 | iocmd->status = bfa_ablk_pf_update(&bfad->bfa.modules.ablk, | 1244 | iocmd->status = bfa_ablk_pf_update(&bfad->bfa.modules.ablk, |
1214 | iocmd->pcifn_id, iocmd->bandwidth, | 1245 | iocmd->pcifn_id, iocmd->bw_min, |
1215 | bfad_hcb_comp, &fcomp); | 1246 | iocmd->bw_max, bfad_hcb_comp, &fcomp); |
1216 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 1247 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
1217 | bfa_trc(bfad, iocmd->status); | 1248 | bfa_trc(bfad, iocmd->status); |
1218 | if (iocmd->status != BFA_STATUS_OK) | 1249 | if (iocmd->status != BFA_STATUS_OK) |
@@ -1736,6 +1767,52 @@ bfad_iocmd_diag_lb_stat(struct bfad_s *bfad, void *cmd) | |||
1736 | } | 1767 | } |
1737 | 1768 | ||
1738 | int | 1769 | int |
1770 | bfad_iocmd_diag_cfg_dport(struct bfad_s *bfad, unsigned int cmd, void *pcmd) | ||
1771 | { | ||
1772 | struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)pcmd; | ||
1773 | unsigned long flags; | ||
1774 | struct bfad_hal_comp fcomp; | ||
1775 | |||
1776 | init_completion(&fcomp.comp); | ||
1777 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
1778 | if (cmd == IOCMD_DIAG_DPORT_ENABLE) | ||
1779 | iocmd->status = bfa_dport_enable(&bfad->bfa, | ||
1780 | bfad_hcb_comp, &fcomp); | ||
1781 | else if (cmd == IOCMD_DIAG_DPORT_DISABLE) | ||
1782 | iocmd->status = bfa_dport_disable(&bfad->bfa, | ||
1783 | bfad_hcb_comp, &fcomp); | ||
1784 | else { | ||
1785 | bfa_trc(bfad, 0); | ||
1786 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1787 | return -EINVAL; | ||
1788 | } | ||
1789 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1790 | |||
1791 | if (iocmd->status != BFA_STATUS_OK) | ||
1792 | bfa_trc(bfad, iocmd->status); | ||
1793 | else { | ||
1794 | wait_for_completion(&fcomp.comp); | ||
1795 | iocmd->status = fcomp.status; | ||
1796 | } | ||
1797 | |||
1798 | return 0; | ||
1799 | } | ||
1800 | |||
1801 | int | ||
1802 | bfad_iocmd_diag_dport_get_state(struct bfad_s *bfad, void *pcmd) | ||
1803 | { | ||
1804 | struct bfa_bsg_diag_dport_get_state_s *iocmd = | ||
1805 | (struct bfa_bsg_diag_dport_get_state_s *)pcmd; | ||
1806 | unsigned long flags; | ||
1807 | |||
1808 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
1809 | iocmd->status = bfa_dport_get_state(&bfad->bfa, &iocmd->state); | ||
1810 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
1811 | |||
1812 | return 0; | ||
1813 | } | ||
1814 | |||
1815 | int | ||
1739 | bfad_iocmd_phy_get_attr(struct bfad_s *bfad, void *cmd) | 1816 | bfad_iocmd_phy_get_attr(struct bfad_s *bfad, void *cmd) |
1740 | { | 1817 | { |
1741 | struct bfa_bsg_phy_attr_s *iocmd = | 1818 | struct bfa_bsg_phy_attr_s *iocmd = |
@@ -2052,7 +2129,7 @@ bfad_iocmd_boot_cfg(struct bfad_s *bfad, void *cmd) | |||
2052 | init_completion(&fcomp.comp); | 2129 | init_completion(&fcomp.comp); |
2053 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2130 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2054 | iocmd->status = bfa_flash_update_part(BFA_FLASH(&bfad->bfa), | 2131 | iocmd->status = bfa_flash_update_part(BFA_FLASH(&bfad->bfa), |
2055 | BFA_FLASH_PART_BOOT, PCI_FUNC(bfad->pcidev->devfn), | 2132 | BFA_FLASH_PART_BOOT, bfad->bfa.ioc.port_id, |
2056 | &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0, | 2133 | &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0, |
2057 | bfad_hcb_comp, &fcomp); | 2134 | bfad_hcb_comp, &fcomp); |
2058 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2135 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
@@ -2074,7 +2151,7 @@ bfad_iocmd_boot_query(struct bfad_s *bfad, void *cmd) | |||
2074 | init_completion(&fcomp.comp); | 2151 | init_completion(&fcomp.comp); |
2075 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2152 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2076 | iocmd->status = bfa_flash_read_part(BFA_FLASH(&bfad->bfa), | 2153 | iocmd->status = bfa_flash_read_part(BFA_FLASH(&bfad->bfa), |
2077 | BFA_FLASH_PART_BOOT, PCI_FUNC(bfad->pcidev->devfn), | 2154 | BFA_FLASH_PART_BOOT, bfad->bfa.ioc.port_id, |
2078 | &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0, | 2155 | &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0, |
2079 | bfad_hcb_comp, &fcomp); | 2156 | bfad_hcb_comp, &fcomp); |
2080 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2157 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
@@ -2161,22 +2238,31 @@ bfad_iocmd_cfg_trunk(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | |||
2161 | 2238 | ||
2162 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2239 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2163 | 2240 | ||
2164 | if (v_cmd == IOCMD_TRUNK_ENABLE) { | 2241 | if (bfa_fcport_is_dport(&bfad->bfa)) |
2165 | trunk->attr.state = BFA_TRUNK_OFFLINE; | 2242 | return BFA_STATUS_DPORT_ERR; |
2166 | bfa_fcport_disable(&bfad->bfa); | ||
2167 | fcport->cfg.trunked = BFA_TRUE; | ||
2168 | } else if (v_cmd == IOCMD_TRUNK_DISABLE) { | ||
2169 | trunk->attr.state = BFA_TRUNK_DISABLED; | ||
2170 | bfa_fcport_disable(&bfad->bfa); | ||
2171 | fcport->cfg.trunked = BFA_FALSE; | ||
2172 | } | ||
2173 | 2243 | ||
2174 | if (!bfa_fcport_is_disabled(&bfad->bfa)) | 2244 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) || |
2175 | bfa_fcport_enable(&bfad->bfa); | 2245 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
2246 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; | ||
2247 | else { | ||
2248 | if (v_cmd == IOCMD_TRUNK_ENABLE) { | ||
2249 | trunk->attr.state = BFA_TRUNK_OFFLINE; | ||
2250 | bfa_fcport_disable(&bfad->bfa); | ||
2251 | fcport->cfg.trunked = BFA_TRUE; | ||
2252 | } else if (v_cmd == IOCMD_TRUNK_DISABLE) { | ||
2253 | trunk->attr.state = BFA_TRUNK_DISABLED; | ||
2254 | bfa_fcport_disable(&bfad->bfa); | ||
2255 | fcport->cfg.trunked = BFA_FALSE; | ||
2256 | } | ||
2257 | |||
2258 | if (!bfa_fcport_is_disabled(&bfad->bfa)) | ||
2259 | bfa_fcport_enable(&bfad->bfa); | ||
2260 | |||
2261 | iocmd->status = BFA_STATUS_OK; | ||
2262 | } | ||
2176 | 2263 | ||
2177 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2264 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2178 | 2265 | ||
2179 | iocmd->status = BFA_STATUS_OK; | ||
2180 | return 0; | 2266 | return 0; |
2181 | } | 2267 | } |
2182 | 2268 | ||
@@ -2189,12 +2275,17 @@ bfad_iocmd_trunk_get_attr(struct bfad_s *bfad, void *cmd) | |||
2189 | unsigned long flags; | 2275 | unsigned long flags; |
2190 | 2276 | ||
2191 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2277 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2192 | memcpy((void *)&iocmd->attr, (void *)&trunk->attr, | 2278 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) || |
2193 | sizeof(struct bfa_trunk_attr_s)); | 2279 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
2194 | iocmd->attr.port_id = bfa_lps_get_base_pid(&bfad->bfa); | 2280 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; |
2281 | else { | ||
2282 | memcpy((void *)&iocmd->attr, (void *)&trunk->attr, | ||
2283 | sizeof(struct bfa_trunk_attr_s)); | ||
2284 | iocmd->attr.port_id = bfa_lps_get_base_pid(&bfad->bfa); | ||
2285 | iocmd->status = BFA_STATUS_OK; | ||
2286 | } | ||
2195 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2287 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2196 | 2288 | ||
2197 | iocmd->status = BFA_STATUS_OK; | ||
2198 | return 0; | 2289 | return 0; |
2199 | } | 2290 | } |
2200 | 2291 | ||
@@ -2207,14 +2298,22 @@ bfad_iocmd_qos(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | |||
2207 | 2298 | ||
2208 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2299 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2209 | if (bfa_ioc_get_type(&bfad->bfa.ioc) == BFA_IOC_TYPE_FC) { | 2300 | if (bfa_ioc_get_type(&bfad->bfa.ioc) == BFA_IOC_TYPE_FC) { |
2210 | if (v_cmd == IOCMD_QOS_ENABLE) | 2301 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
2211 | fcport->cfg.qos_enabled = BFA_TRUE; | 2302 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
2212 | else if (v_cmd == IOCMD_QOS_DISABLE) | 2303 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; |
2213 | fcport->cfg.qos_enabled = BFA_FALSE; | 2304 | else { |
2305 | if (v_cmd == IOCMD_QOS_ENABLE) | ||
2306 | fcport->cfg.qos_enabled = BFA_TRUE; | ||
2307 | else if (v_cmd == IOCMD_QOS_DISABLE) { | ||
2308 | fcport->cfg.qos_enabled = BFA_FALSE; | ||
2309 | fcport->cfg.qos_bw.high = BFA_QOS_BW_HIGH; | ||
2310 | fcport->cfg.qos_bw.med = BFA_QOS_BW_MED; | ||
2311 | fcport->cfg.qos_bw.low = BFA_QOS_BW_LOW; | ||
2312 | } | ||
2313 | } | ||
2214 | } | 2314 | } |
2215 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2315 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2216 | 2316 | ||
2217 | iocmd->status = BFA_STATUS_OK; | ||
2218 | return 0; | 2317 | return 0; |
2219 | } | 2318 | } |
2220 | 2319 | ||
@@ -2226,11 +2325,21 @@ bfad_iocmd_qos_get_attr(struct bfad_s *bfad, void *cmd) | |||
2226 | unsigned long flags; | 2325 | unsigned long flags; |
2227 | 2326 | ||
2228 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2327 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2229 | iocmd->attr.state = fcport->qos_attr.state; | 2328 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
2230 | iocmd->attr.total_bb_cr = be32_to_cpu(fcport->qos_attr.total_bb_cr); | 2329 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) |
2330 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; | ||
2331 | else { | ||
2332 | iocmd->attr.state = fcport->qos_attr.state; | ||
2333 | iocmd->attr.total_bb_cr = | ||
2334 | be32_to_cpu(fcport->qos_attr.total_bb_cr); | ||
2335 | iocmd->attr.qos_bw.high = fcport->cfg.qos_bw.high; | ||
2336 | iocmd->attr.qos_bw.med = fcport->cfg.qos_bw.med; | ||
2337 | iocmd->attr.qos_bw.low = fcport->cfg.qos_bw.low; | ||
2338 | iocmd->attr.qos_bw_op = fcport->qos_attr.qos_bw_op; | ||
2339 | iocmd->status = BFA_STATUS_OK; | ||
2340 | } | ||
2231 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2341 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2232 | 2342 | ||
2233 | iocmd->status = BFA_STATUS_OK; | ||
2234 | return 0; | 2343 | return 0; |
2235 | } | 2344 | } |
2236 | 2345 | ||
@@ -2274,6 +2383,7 @@ bfad_iocmd_qos_get_stats(struct bfad_s *bfad, void *cmd) | |||
2274 | struct bfad_hal_comp fcomp; | 2383 | struct bfad_hal_comp fcomp; |
2275 | unsigned long flags; | 2384 | unsigned long flags; |
2276 | struct bfa_cb_pending_q_s cb_qe; | 2385 | struct bfa_cb_pending_q_s cb_qe; |
2386 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); | ||
2277 | 2387 | ||
2278 | init_completion(&fcomp.comp); | 2388 | init_completion(&fcomp.comp); |
2279 | bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, | 2389 | bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, |
@@ -2281,7 +2391,11 @@ bfad_iocmd_qos_get_stats(struct bfad_s *bfad, void *cmd) | |||
2281 | 2391 | ||
2282 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2392 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2283 | WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); | 2393 | WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); |
2284 | iocmd->status = bfa_fcport_get_stats(&bfad->bfa, &cb_qe); | 2394 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
2395 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) | ||
2396 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; | ||
2397 | else | ||
2398 | iocmd->status = bfa_fcport_get_stats(&bfad->bfa, &cb_qe); | ||
2285 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2399 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2286 | if (iocmd->status != BFA_STATUS_OK) { | 2400 | if (iocmd->status != BFA_STATUS_OK) { |
2287 | bfa_trc(bfad, iocmd->status); | 2401 | bfa_trc(bfad, iocmd->status); |
@@ -2300,6 +2414,7 @@ bfad_iocmd_qos_reset_stats(struct bfad_s *bfad, void *cmd) | |||
2300 | struct bfad_hal_comp fcomp; | 2414 | struct bfad_hal_comp fcomp; |
2301 | unsigned long flags; | 2415 | unsigned long flags; |
2302 | struct bfa_cb_pending_q_s cb_qe; | 2416 | struct bfa_cb_pending_q_s cb_qe; |
2417 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); | ||
2303 | 2418 | ||
2304 | init_completion(&fcomp.comp); | 2419 | init_completion(&fcomp.comp); |
2305 | bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, | 2420 | bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, |
@@ -2307,7 +2422,11 @@ bfad_iocmd_qos_reset_stats(struct bfad_s *bfad, void *cmd) | |||
2307 | 2422 | ||
2308 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 2423 | spin_lock_irqsave(&bfad->bfad_lock, flags); |
2309 | WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); | 2424 | WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); |
2310 | iocmd->status = bfa_fcport_clear_stats(&bfad->bfa, &cb_qe); | 2425 | if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) && |
2426 | (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)) | ||
2427 | iocmd->status = BFA_STATUS_TOPOLOGY_LOOP; | ||
2428 | else | ||
2429 | iocmd->status = bfa_fcport_clear_stats(&bfad->bfa, &cb_qe); | ||
2311 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 2430 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); |
2312 | if (iocmd->status != BFA_STATUS_OK) { | 2431 | if (iocmd->status != BFA_STATUS_OK) { |
2313 | bfa_trc(bfad, iocmd->status); | 2432 | bfa_trc(bfad, iocmd->status); |
@@ -2435,6 +2554,139 @@ bfad_iocmd_fcpim_cfg_lunmask(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) | |||
2435 | return 0; | 2554 | return 0; |
2436 | } | 2555 | } |
2437 | 2556 | ||
2557 | int | ||
2558 | bfad_iocmd_fcpim_throttle_query(struct bfad_s *bfad, void *cmd) | ||
2559 | { | ||
2560 | struct bfa_bsg_fcpim_throttle_s *iocmd = | ||
2561 | (struct bfa_bsg_fcpim_throttle_s *)cmd; | ||
2562 | unsigned long flags; | ||
2563 | |||
2564 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2565 | iocmd->status = bfa_fcpim_throttle_get(&bfad->bfa, | ||
2566 | (void *)&iocmd->throttle); | ||
2567 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2568 | |||
2569 | return 0; | ||
2570 | } | ||
2571 | |||
2572 | int | ||
2573 | bfad_iocmd_fcpim_throttle_set(struct bfad_s *bfad, void *cmd) | ||
2574 | { | ||
2575 | struct bfa_bsg_fcpim_throttle_s *iocmd = | ||
2576 | (struct bfa_bsg_fcpim_throttle_s *)cmd; | ||
2577 | unsigned long flags; | ||
2578 | |||
2579 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2580 | iocmd->status = bfa_fcpim_throttle_set(&bfad->bfa, | ||
2581 | iocmd->throttle.cfg_value); | ||
2582 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2583 | |||
2584 | return 0; | ||
2585 | } | ||
2586 | |||
2587 | int | ||
2588 | bfad_iocmd_tfru_read(struct bfad_s *bfad, void *cmd) | ||
2589 | { | ||
2590 | struct bfa_bsg_tfru_s *iocmd = | ||
2591 | (struct bfa_bsg_tfru_s *)cmd; | ||
2592 | struct bfad_hal_comp fcomp; | ||
2593 | unsigned long flags = 0; | ||
2594 | |||
2595 | init_completion(&fcomp.comp); | ||
2596 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2597 | iocmd->status = bfa_tfru_read(BFA_FRU(&bfad->bfa), | ||
2598 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2599 | bfad_hcb_comp, &fcomp); | ||
2600 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2601 | if (iocmd->status == BFA_STATUS_OK) { | ||
2602 | wait_for_completion(&fcomp.comp); | ||
2603 | iocmd->status = fcomp.status; | ||
2604 | } | ||
2605 | |||
2606 | return 0; | ||
2607 | } | ||
2608 | |||
2609 | int | ||
2610 | bfad_iocmd_tfru_write(struct bfad_s *bfad, void *cmd) | ||
2611 | { | ||
2612 | struct bfa_bsg_tfru_s *iocmd = | ||
2613 | (struct bfa_bsg_tfru_s *)cmd; | ||
2614 | struct bfad_hal_comp fcomp; | ||
2615 | unsigned long flags = 0; | ||
2616 | |||
2617 | init_completion(&fcomp.comp); | ||
2618 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2619 | iocmd->status = bfa_tfru_write(BFA_FRU(&bfad->bfa), | ||
2620 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2621 | bfad_hcb_comp, &fcomp); | ||
2622 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2623 | if (iocmd->status == BFA_STATUS_OK) { | ||
2624 | wait_for_completion(&fcomp.comp); | ||
2625 | iocmd->status = fcomp.status; | ||
2626 | } | ||
2627 | |||
2628 | return 0; | ||
2629 | } | ||
2630 | |||
2631 | int | ||
2632 | bfad_iocmd_fruvpd_read(struct bfad_s *bfad, void *cmd) | ||
2633 | { | ||
2634 | struct bfa_bsg_fruvpd_s *iocmd = | ||
2635 | (struct bfa_bsg_fruvpd_s *)cmd; | ||
2636 | struct bfad_hal_comp fcomp; | ||
2637 | unsigned long flags = 0; | ||
2638 | |||
2639 | init_completion(&fcomp.comp); | ||
2640 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2641 | iocmd->status = bfa_fruvpd_read(BFA_FRU(&bfad->bfa), | ||
2642 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2643 | bfad_hcb_comp, &fcomp); | ||
2644 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2645 | if (iocmd->status == BFA_STATUS_OK) { | ||
2646 | wait_for_completion(&fcomp.comp); | ||
2647 | iocmd->status = fcomp.status; | ||
2648 | } | ||
2649 | |||
2650 | return 0; | ||
2651 | } | ||
2652 | |||
2653 | int | ||
2654 | bfad_iocmd_fruvpd_update(struct bfad_s *bfad, void *cmd) | ||
2655 | { | ||
2656 | struct bfa_bsg_fruvpd_s *iocmd = | ||
2657 | (struct bfa_bsg_fruvpd_s *)cmd; | ||
2658 | struct bfad_hal_comp fcomp; | ||
2659 | unsigned long flags = 0; | ||
2660 | |||
2661 | init_completion(&fcomp.comp); | ||
2662 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2663 | iocmd->status = bfa_fruvpd_update(BFA_FRU(&bfad->bfa), | ||
2664 | &iocmd->data, iocmd->len, iocmd->offset, | ||
2665 | bfad_hcb_comp, &fcomp); | ||
2666 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2667 | if (iocmd->status == BFA_STATUS_OK) { | ||
2668 | wait_for_completion(&fcomp.comp); | ||
2669 | iocmd->status = fcomp.status; | ||
2670 | } | ||
2671 | |||
2672 | return 0; | ||
2673 | } | ||
2674 | |||
2675 | int | ||
2676 | bfad_iocmd_fruvpd_get_max_size(struct bfad_s *bfad, void *cmd) | ||
2677 | { | ||
2678 | struct bfa_bsg_fruvpd_max_size_s *iocmd = | ||
2679 | (struct bfa_bsg_fruvpd_max_size_s *)cmd; | ||
2680 | unsigned long flags = 0; | ||
2681 | |||
2682 | spin_lock_irqsave(&bfad->bfad_lock, flags); | ||
2683 | iocmd->status = bfa_fruvpd_get_max_size(BFA_FRU(&bfad->bfa), | ||
2684 | &iocmd->max_size); | ||
2685 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | ||
2686 | |||
2687 | return 0; | ||
2688 | } | ||
2689 | |||
2438 | static int | 2690 | static int |
2439 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | 2691 | bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, |
2440 | unsigned int payload_len) | 2692 | unsigned int payload_len) |
@@ -2660,6 +2912,13 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
2660 | case IOCMD_DIAG_LB_STAT: | 2912 | case IOCMD_DIAG_LB_STAT: |
2661 | rc = bfad_iocmd_diag_lb_stat(bfad, iocmd); | 2913 | rc = bfad_iocmd_diag_lb_stat(bfad, iocmd); |
2662 | break; | 2914 | break; |
2915 | case IOCMD_DIAG_DPORT_ENABLE: | ||
2916 | case IOCMD_DIAG_DPORT_DISABLE: | ||
2917 | rc = bfad_iocmd_diag_cfg_dport(bfad, cmd, iocmd); | ||
2918 | break; | ||
2919 | case IOCMD_DIAG_DPORT_GET_STATE: | ||
2920 | rc = bfad_iocmd_diag_dport_get_state(bfad, iocmd); | ||
2921 | break; | ||
2663 | case IOCMD_PHY_GET_ATTR: | 2922 | case IOCMD_PHY_GET_ATTR: |
2664 | rc = bfad_iocmd_phy_get_attr(bfad, iocmd); | 2923 | rc = bfad_iocmd_phy_get_attr(bfad, iocmd); |
2665 | break; | 2924 | break; |
@@ -2741,6 +3000,9 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
2741 | case IOCMD_QOS_RESET_STATS: | 3000 | case IOCMD_QOS_RESET_STATS: |
2742 | rc = bfad_iocmd_qos_reset_stats(bfad, iocmd); | 3001 | rc = bfad_iocmd_qos_reset_stats(bfad, iocmd); |
2743 | break; | 3002 | break; |
3003 | case IOCMD_QOS_SET_BW: | ||
3004 | rc = bfad_iocmd_qos_set_bw(bfad, iocmd); | ||
3005 | break; | ||
2744 | case IOCMD_VF_GET_STATS: | 3006 | case IOCMD_VF_GET_STATS: |
2745 | rc = bfad_iocmd_vf_get_stats(bfad, iocmd); | 3007 | rc = bfad_iocmd_vf_get_stats(bfad, iocmd); |
2746 | break; | 3008 | break; |
@@ -2759,6 +3021,29 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, | |||
2759 | case IOCMD_FCPIM_LUNMASK_DELETE: | 3021 | case IOCMD_FCPIM_LUNMASK_DELETE: |
2760 | rc = bfad_iocmd_fcpim_cfg_lunmask(bfad, iocmd, cmd); | 3022 | rc = bfad_iocmd_fcpim_cfg_lunmask(bfad, iocmd, cmd); |
2761 | break; | 3023 | break; |
3024 | case IOCMD_FCPIM_THROTTLE_QUERY: | ||
3025 | rc = bfad_iocmd_fcpim_throttle_query(bfad, iocmd); | ||
3026 | break; | ||
3027 | case IOCMD_FCPIM_THROTTLE_SET: | ||
3028 | rc = bfad_iocmd_fcpim_throttle_set(bfad, iocmd); | ||
3029 | break; | ||
3030 | /* TFRU */ | ||
3031 | case IOCMD_TFRU_READ: | ||
3032 | rc = bfad_iocmd_tfru_read(bfad, iocmd); | ||
3033 | break; | ||
3034 | case IOCMD_TFRU_WRITE: | ||
3035 | rc = bfad_iocmd_tfru_write(bfad, iocmd); | ||
3036 | break; | ||
3037 | /* FRU */ | ||
3038 | case IOCMD_FRUVPD_READ: | ||
3039 | rc = bfad_iocmd_fruvpd_read(bfad, iocmd); | ||
3040 | break; | ||
3041 | case IOCMD_FRUVPD_UPDATE: | ||
3042 | rc = bfad_iocmd_fruvpd_update(bfad, iocmd); | ||
3043 | break; | ||
3044 | case IOCMD_FRUVPD_GET_MAX_SIZE: | ||
3045 | rc = bfad_iocmd_fruvpd_get_max_size(bfad, iocmd); | ||
3046 | break; | ||
2762 | default: | 3047 | default: |
2763 | rc = -EINVAL; | 3048 | rc = -EINVAL; |
2764 | break; | 3049 | break; |