Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


 843         int              idx;
 844         uint32_t         cmd_len = fpkt->pkt_cmdlen;
 845 
 846         /*
 847          * Ensure it's 4-byte aligned
 848          */
 849         cmd_len = P2ROUNDUP(cmd_len, 4);
 850 
 851         /*
 852          * Allocate CT request frame
 853          */
 854         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
 855             cmd_len + FCFH_SIZE, NULL);
 856         if (frm == NULL) {
 857                 FCOEI_LOG(__FUNCTION__, "failed to alloc: %p", xch);
 858                 return;
 859         }
 860 
 861         bzero(frm->frm_payload, cmd_len);
 862         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
 863         atomic_add_32(xch->xch_cnt, 1);
 864 
 865         FFM_R_CTL(fpkt->pkt_cmd_fhdr.r_ctl, frm);
 866         FFM_D_ID(fpkt->pkt_cmd_fhdr.d_id, frm);
 867         FFM_S_ID(fpkt->pkt_cmd_fhdr.s_id, frm);
 868         FFM_TYPE(fpkt->pkt_cmd_fhdr.type, frm);
 869         FFM_F_CTL(fpkt->pkt_cmd_fhdr.f_ctl, frm);
 870         FFM_OXID(xch->xch_oxid, frm);
 871         FFM_RXID(xch->xch_rxid, frm);
 872         fcoei_init_ifm(frm, xch);
 873 
 874         /*
 875          * CT header (FC payload)
 876          */
 877         offset = 0;
 878         FCOE_V2B_1(ct->ct_rev, FPLD + offset);
 879 
 880         offset = 1;
 881         FCOE_V2B_3(ct->ct_inid, FPLD + offset);
 882 
 883         offset = 4;


1039 {
1040         fc_packet_t     *fpkt = xch->xch_fpkt;
1041         fcoe_frame_t    *frm;
1042         fcp_cmd_t       *fcp_cmd_iu = (fcp_cmd_t *)(void *)fpkt->pkt_cmd;
1043         int              offset = 0;
1044 
1045         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1046         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1047             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1048         if (!frm) {
1049                 ASSERT(0);
1050         } else {
1051                 fcoei_init_ifm(frm, xch);
1052                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1053         }
1054 
1055         /*
1056          * This will affect timing check
1057          */
1058         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
1059         atomic_add_32(xch->xch_cnt, 1);
1060 
1061         /*
1062          * Set exchange residual bytes
1063          */
1064         xch->xch_resid = (int)fpkt->pkt_datalen;
1065 
1066         /*
1067          * Fill FCP command IU
1068          *
1069          * fcp_ent_addr
1070          */
1071         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_0,
1072             frm->frm_payload + offset);
1073         offset += 2;
1074         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_1,
1075             frm->frm_payload + offset);
1076         offset += 2;
1077         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_2,
1078             frm->frm_payload + offset);
1079         offset += 2;


1143 fcoei_initiate_els_req(fcoei_exchange_t *xch)
1144 {
1145         fc_packet_t     *fpkt = xch->xch_fpkt;
1146         fcoe_frame_t    *frm;
1147         ls_code_t       *els_code;
1148 
1149         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1150         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1151             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1152         if (!frm) {
1153                 ASSERT(0);
1154         } else {
1155                 fcoei_init_ifm(frm, xch);
1156                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1157         }
1158 
1159         /*
1160          * This will affect timing check
1161          */
1162         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
1163         atomic_add_32(xch->xch_cnt, 1);
1164 
1165         els_code = (ls_code_t *)(void *)fpkt->pkt_cmd;
1166         switch (els_code->ls_code) {
1167         case LA_ELS_FLOGI:
1168                 /*
1169                  * For FLOGI, we expect response within E_D_TOV
1170                  */
1171                 xch->xch_start_tick = ddi_get_lbolt();
1172                 xch->xch_end_tick = xch->xch_start_tick +
1173                     FCOE_SEC2TICK(2);
1174                 xch->xch_ss->ss_flags &= ~SS_FLAG_FLOGI_FAILED;
1175                 /* FALLTHROUGH */
1176 
1177         case LA_ELS_PLOGI:
1178                 fcoei_fill_els_logi_cmd(fpkt, frm);
1179                 break;
1180 
1181         case LA_ELS_PRLI:
1182                 fcoei_fill_els_prli_cmd(fpkt, frm);
1183                 break;


1250 static void
1251 fcoei_initiate_els_resp(fcoei_exchange_t *xch)
1252 {
1253         fc_packet_t     *fpkt = xch->xch_fpkt;
1254         fcoe_frame_t    *frm;
1255 
1256         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1257         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1258             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1259         if (!frm) {
1260                 ASSERT(0);
1261         } else {
1262                 fcoei_init_ifm(frm, xch);
1263                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1264         }
1265 
1266         /*
1267          * This will affect timing check
1268          */
1269         xch->xch_cnt = xch->xch_ss->ss_unsol_cnt;
1270         atomic_add_32(xch->xch_cnt, 1);
1271 
1272         /*
1273          * Set ifm_rctl
1274          */
1275         FRM2IFM(frm)->ifm_rctl = fpkt->pkt_cmd_fhdr.r_ctl;
1276 
1277         /*
1278          * FCPH
1279          */
1280         FFM_R_CTL(fpkt->pkt_cmd_fhdr.r_ctl, frm);
1281         FFM_D_ID(fpkt->pkt_cmd_fhdr.d_id, frm);
1282         FFM_S_ID(fpkt->pkt_cmd_fhdr.s_id, frm);
1283         FFM_TYPE(fpkt->pkt_cmd_fhdr.type, frm);
1284         FFM_F_CTL(0x980000, frm);
1285         FFM_OXID(xch->xch_oxid, frm);
1286         FFM_RXID(xch->xch_rxid, frm);
1287 
1288         switch (((uint8_t *)&fpkt->pkt_fca_rsvd1)[0]) {
1289         case LA_ELS_FLOGI:
1290                 fcoei_fill_els_logi_resp(fpkt, frm);




 843         int              idx;
 844         uint32_t         cmd_len = fpkt->pkt_cmdlen;
 845 
 846         /*
 847          * Ensure it's 4-byte aligned
 848          */
 849         cmd_len = P2ROUNDUP(cmd_len, 4);
 850 
 851         /*
 852          * Allocate CT request frame
 853          */
 854         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
 855             cmd_len + FCFH_SIZE, NULL);
 856         if (frm == NULL) {
 857                 FCOEI_LOG(__FUNCTION__, "failed to alloc: %p", xch);
 858                 return;
 859         }
 860 
 861         bzero(frm->frm_payload, cmd_len);
 862         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
 863         atomic_inc_32(xch->xch_cnt);
 864 
 865         FFM_R_CTL(fpkt->pkt_cmd_fhdr.r_ctl, frm);
 866         FFM_D_ID(fpkt->pkt_cmd_fhdr.d_id, frm);
 867         FFM_S_ID(fpkt->pkt_cmd_fhdr.s_id, frm);
 868         FFM_TYPE(fpkt->pkt_cmd_fhdr.type, frm);
 869         FFM_F_CTL(fpkt->pkt_cmd_fhdr.f_ctl, frm);
 870         FFM_OXID(xch->xch_oxid, frm);
 871         FFM_RXID(xch->xch_rxid, frm);
 872         fcoei_init_ifm(frm, xch);
 873 
 874         /*
 875          * CT header (FC payload)
 876          */
 877         offset = 0;
 878         FCOE_V2B_1(ct->ct_rev, FPLD + offset);
 879 
 880         offset = 1;
 881         FCOE_V2B_3(ct->ct_inid, FPLD + offset);
 882 
 883         offset = 4;


1039 {
1040         fc_packet_t     *fpkt = xch->xch_fpkt;
1041         fcoe_frame_t    *frm;
1042         fcp_cmd_t       *fcp_cmd_iu = (fcp_cmd_t *)(void *)fpkt->pkt_cmd;
1043         int              offset = 0;
1044 
1045         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1046         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1047             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1048         if (!frm) {
1049                 ASSERT(0);
1050         } else {
1051                 fcoei_init_ifm(frm, xch);
1052                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1053         }
1054 
1055         /*
1056          * This will affect timing check
1057          */
1058         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
1059         atomic_inc_32(xch->xch_cnt);
1060 
1061         /*
1062          * Set exchange residual bytes
1063          */
1064         xch->xch_resid = (int)fpkt->pkt_datalen;
1065 
1066         /*
1067          * Fill FCP command IU
1068          *
1069          * fcp_ent_addr
1070          */
1071         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_0,
1072             frm->frm_payload + offset);
1073         offset += 2;
1074         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_1,
1075             frm->frm_payload + offset);
1076         offset += 2;
1077         FCOE_V2B_2(fcp_cmd_iu->fcp_ent_addr.ent_addr_2,
1078             frm->frm_payload + offset);
1079         offset += 2;


1143 fcoei_initiate_els_req(fcoei_exchange_t *xch)
1144 {
1145         fc_packet_t     *fpkt = xch->xch_fpkt;
1146         fcoe_frame_t    *frm;
1147         ls_code_t       *els_code;
1148 
1149         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1150         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1151             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1152         if (!frm) {
1153                 ASSERT(0);
1154         } else {
1155                 fcoei_init_ifm(frm, xch);
1156                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1157         }
1158 
1159         /*
1160          * This will affect timing check
1161          */
1162         xch->xch_cnt = xch->xch_ss->ss_sol_cnt;
1163         atomic_inc_32(xch->xch_cnt);
1164 
1165         els_code = (ls_code_t *)(void *)fpkt->pkt_cmd;
1166         switch (els_code->ls_code) {
1167         case LA_ELS_FLOGI:
1168                 /*
1169                  * For FLOGI, we expect response within E_D_TOV
1170                  */
1171                 xch->xch_start_tick = ddi_get_lbolt();
1172                 xch->xch_end_tick = xch->xch_start_tick +
1173                     FCOE_SEC2TICK(2);
1174                 xch->xch_ss->ss_flags &= ~SS_FLAG_FLOGI_FAILED;
1175                 /* FALLTHROUGH */
1176 
1177         case LA_ELS_PLOGI:
1178                 fcoei_fill_els_logi_cmd(fpkt, frm);
1179                 break;
1180 
1181         case LA_ELS_PRLI:
1182                 fcoei_fill_els_prli_cmd(fpkt, frm);
1183                 break;


1250 static void
1251 fcoei_initiate_els_resp(fcoei_exchange_t *xch)
1252 {
1253         fc_packet_t     *fpkt = xch->xch_fpkt;
1254         fcoe_frame_t    *frm;
1255 
1256         ASSERT((fpkt->pkt_cmdlen % 4) == 0);
1257         frm = xch->xch_ss->ss_eport->eport_alloc_frame(xch->xch_ss->ss_eport,
1258             fpkt->pkt_cmdlen + FCFH_SIZE, NULL);
1259         if (!frm) {
1260                 ASSERT(0);
1261         } else {
1262                 fcoei_init_ifm(frm, xch);
1263                 bzero(frm->frm_payload, fpkt->pkt_cmdlen);
1264         }
1265 
1266         /*
1267          * This will affect timing check
1268          */
1269         xch->xch_cnt = xch->xch_ss->ss_unsol_cnt;
1270         atomic_inc_32(xch->xch_cnt);
1271 
1272         /*
1273          * Set ifm_rctl
1274          */
1275         FRM2IFM(frm)->ifm_rctl = fpkt->pkt_cmd_fhdr.r_ctl;
1276 
1277         /*
1278          * FCPH
1279          */
1280         FFM_R_CTL(fpkt->pkt_cmd_fhdr.r_ctl, frm);
1281         FFM_D_ID(fpkt->pkt_cmd_fhdr.d_id, frm);
1282         FFM_S_ID(fpkt->pkt_cmd_fhdr.s_id, frm);
1283         FFM_TYPE(fpkt->pkt_cmd_fhdr.type, frm);
1284         FFM_F_CTL(0x980000, frm);
1285         FFM_OXID(xch->xch_oxid, frm);
1286         FFM_RXID(xch->xch_rxid, frm);
1287 
1288         switch (((uint8_t *)&fpkt->pkt_fca_rsvd1)[0]) {
1289         case LA_ELS_FLOGI:
1290                 fcoei_fill_els_logi_resp(fpkt, frm);