| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2005-2014 Brocade Communications Systems, Inc. |
|---|
| 3 | 4 | * Copyright (c) 2014- QLogic Corporation. |
|---|
| .. | .. |
|---|
| 5 | 6 | * www.qlogic.com |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 10 | | - * under the terms of the GNU General Public License (GPL) Version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 14 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 16 | | - * General Public License for more details. |
|---|
| 17 | 9 | */ |
|---|
| 18 | 10 | /* |
|---|
| 19 | 11 | * fcbuild.c - FC link service frame building and parsing routines |
|---|
| .. | .. |
|---|
| 188 | 180 | fchs->d_id = d_id; |
|---|
| 189 | 181 | fchs->s_id = s_id; |
|---|
| 190 | 182 | fchs->ox_id = ox_id; |
|---|
| 191 | | -} |
|---|
| 192 | | - |
|---|
| 193 | | -enum fc_parse_status |
|---|
| 194 | | -fc_els_rsp_parse(struct fchs_s *fchs, int len) |
|---|
| 195 | | -{ |
|---|
| 196 | | - struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); |
|---|
| 197 | | - struct fc_ls_rjt_s *ls_rjt = (struct fc_ls_rjt_s *) els_cmd; |
|---|
| 198 | | - |
|---|
| 199 | | - len = len; |
|---|
| 200 | | - |
|---|
| 201 | | - switch (els_cmd->els_code) { |
|---|
| 202 | | - case FC_ELS_LS_RJT: |
|---|
| 203 | | - if (ls_rjt->reason_code == FC_LS_RJT_RSN_LOGICAL_BUSY) |
|---|
| 204 | | - return FC_PARSE_BUSY; |
|---|
| 205 | | - else |
|---|
| 206 | | - return FC_PARSE_FAILURE; |
|---|
| 207 | | - |
|---|
| 208 | | - case FC_ELS_ACC: |
|---|
| 209 | | - return FC_PARSE_OK; |
|---|
| 210 | | - } |
|---|
| 211 | | - return FC_PARSE_OK; |
|---|
| 212 | 183 | } |
|---|
| 213 | 184 | |
|---|
| 214 | 185 | static void |
|---|
| .. | .. |
|---|
| 831 | 802 | } |
|---|
| 832 | 803 | |
|---|
| 833 | 804 | u16 |
|---|
| 834 | | -fc_logo_rsp_parse(struct fchs_s *fchs, int len) |
|---|
| 835 | | -{ |
|---|
| 836 | | - struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); |
|---|
| 837 | | - |
|---|
| 838 | | - len = len; |
|---|
| 839 | | - if (els_cmd->els_code != FC_ELS_ACC) |
|---|
| 840 | | - return FC_PARSE_FAILURE; |
|---|
| 841 | | - |
|---|
| 842 | | - return FC_PARSE_OK; |
|---|
| 843 | | -} |
|---|
| 844 | | - |
|---|
| 845 | | -u16 |
|---|
| 846 | 805 | fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id, |
|---|
| 847 | 806 | wwn_t port_name, wwn_t node_name, u16 pdu_size) |
|---|
| 848 | 807 | { |
|---|
| .. | .. |
|---|
| 908 | 867 | } |
|---|
| 909 | 868 | |
|---|
| 910 | 869 | u16 |
|---|
| 911 | | -fc_prlo_rsp_parse(struct fchs_s *fchs, int len) |
|---|
| 912 | | -{ |
|---|
| 913 | | - struct fc_prlo_acc_s *prlo = (struct fc_prlo_acc_s *) (fchs + 1); |
|---|
| 914 | | - int num_pages = 0; |
|---|
| 915 | | - int page = 0; |
|---|
| 916 | | - |
|---|
| 917 | | - len = len; |
|---|
| 918 | | - |
|---|
| 919 | | - if (prlo->command != FC_ELS_ACC) |
|---|
| 920 | | - return FC_PARSE_FAILURE; |
|---|
| 921 | | - |
|---|
| 922 | | - num_pages = ((be16_to_cpu(prlo->payload_len)) - 4) / 16; |
|---|
| 923 | | - |
|---|
| 924 | | - for (page = 0; page < num_pages; page++) { |
|---|
| 925 | | - if (prlo->prlo_acc_params[page].type != FC_TYPE_FCP) |
|---|
| 926 | | - return FC_PARSE_FAILURE; |
|---|
| 927 | | - |
|---|
| 928 | | - if (prlo->prlo_acc_params[page].opa_valid != 0) |
|---|
| 929 | | - return FC_PARSE_FAILURE; |
|---|
| 930 | | - |
|---|
| 931 | | - if (prlo->prlo_acc_params[page].rpa_valid != 0) |
|---|
| 932 | | - return FC_PARSE_FAILURE; |
|---|
| 933 | | - |
|---|
| 934 | | - if (prlo->prlo_acc_params[page].orig_process_assc != 0) |
|---|
| 935 | | - return FC_PARSE_FAILURE; |
|---|
| 936 | | - |
|---|
| 937 | | - if (prlo->prlo_acc_params[page].resp_process_assc != 0) |
|---|
| 938 | | - return FC_PARSE_FAILURE; |
|---|
| 939 | | - } |
|---|
| 940 | | - return FC_PARSE_OK; |
|---|
| 941 | | - |
|---|
| 942 | | -} |
|---|
| 943 | | - |
|---|
| 944 | | -u16 |
|---|
| 945 | 870 | fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id, |
|---|
| 946 | 871 | int num_pages, enum fc_tprlo_type tprlo_type, u32 tpr_id) |
|---|
| 947 | 872 | { |
|---|
| .. | .. |
|---|
| 969 | 894 | } |
|---|
| 970 | 895 | |
|---|
| 971 | 896 | return be16_to_cpu(tprlo->payload_len); |
|---|
| 972 | | -} |
|---|
| 973 | | - |
|---|
| 974 | | -u16 |
|---|
| 975 | | -fc_tprlo_rsp_parse(struct fchs_s *fchs, int len) |
|---|
| 976 | | -{ |
|---|
| 977 | | - struct fc_tprlo_acc_s *tprlo = (struct fc_tprlo_acc_s *) (fchs + 1); |
|---|
| 978 | | - int num_pages = 0; |
|---|
| 979 | | - int page = 0; |
|---|
| 980 | | - |
|---|
| 981 | | - len = len; |
|---|
| 982 | | - |
|---|
| 983 | | - if (tprlo->command != FC_ELS_ACC) |
|---|
| 984 | | - return FC_PARSE_ACC_INVAL; |
|---|
| 985 | | - |
|---|
| 986 | | - num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16; |
|---|
| 987 | | - |
|---|
| 988 | | - for (page = 0; page < num_pages; page++) { |
|---|
| 989 | | - if (tprlo->tprlo_acc_params[page].type != FC_TYPE_FCP) |
|---|
| 990 | | - return FC_PARSE_NOT_FCP; |
|---|
| 991 | | - if (tprlo->tprlo_acc_params[page].opa_valid != 0) |
|---|
| 992 | | - return FC_PARSE_OPAFLAG_INVAL; |
|---|
| 993 | | - if (tprlo->tprlo_acc_params[page].rpa_valid != 0) |
|---|
| 994 | | - return FC_PARSE_RPAFLAG_INVAL; |
|---|
| 995 | | - if (tprlo->tprlo_acc_params[page].orig_process_assc != 0) |
|---|
| 996 | | - return FC_PARSE_OPA_INVAL; |
|---|
| 997 | | - if (tprlo->tprlo_acc_params[page].resp_process_assc != 0) |
|---|
| 998 | | - return FC_PARSE_RPA_INVAL; |
|---|
| 999 | | - } |
|---|
| 1000 | | - return FC_PARSE_OK; |
|---|
| 1001 | | -} |
|---|
| 1002 | | - |
|---|
| 1003 | | -enum fc_parse_status |
|---|
| 1004 | | -fc_rrq_rsp_parse(struct fchs_s *fchs, int len) |
|---|
| 1005 | | -{ |
|---|
| 1006 | | - struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); |
|---|
| 1007 | | - |
|---|
| 1008 | | - len = len; |
|---|
| 1009 | | - if (els_cmd->els_code != FC_ELS_ACC) |
|---|
| 1010 | | - return FC_PARSE_FAILURE; |
|---|
| 1011 | | - |
|---|
| 1012 | | - return FC_PARSE_OK; |
|---|
| 1013 | 897 | } |
|---|
| 1014 | 898 | |
|---|
| 1015 | 899 | u16 |
|---|