Lines Matching full:ch
72 * ch The channel where this skb has been received.
75 void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) in ctcm_unpack_skb() argument
77 struct net_device *dev = ch->netdev; in ctcm_unpack_skb()
91 if ((ch->protocol == CTCM_PROTO_S390) && in ctcm_unpack_skb()
93 if (!(ch->logflags & LOG_FLAG_ILLEGALPKT)) { in ctcm_unpack_skb()
94 ch->logflags |= LOG_FLAG_ILLEGALPKT; in ctcm_unpack_skb()
113 if (!(ch->logflags & LOG_FLAG_ILLEGALSIZE)) { in ctcm_unpack_skb()
119 ch->logflags |= LOG_FLAG_ILLEGALSIZE; in ctcm_unpack_skb()
130 if (!(ch->logflags & LOG_FLAG_OVERRUN)) { in ctcm_unpack_skb()
135 ch->logflags |= LOG_FLAG_OVERRUN; in ctcm_unpack_skb()
147 if (!(ch->logflags & LOG_FLAG_NOMEM)) { in ctcm_unpack_skb()
151 ch->logflags |= LOG_FLAG_NOMEM; in ctcm_unpack_skb()
166 ch->logflags = 0; in ctcm_unpack_skb()
175 ch->logflags |= LOG_FLAG_OVERRUN; in ctcm_unpack_skb()
186 * ch Pointer to channel struct to be released.
188 static void channel_free(struct channel *ch) in channel_free() argument
190 CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, "%s(%s)", CTCM_FUNTAIL, ch->id); in channel_free()
191 ch->flags &= ~CHANNEL_FLAGS_INUSE; in channel_free()
192 fsm_newstate(ch->fsm, CTC_STATE_IDLE); in channel_free()
198 * ch Pointer to channel struct to be released.
200 static void channel_remove(struct channel *ch) in channel_remove() argument
206 if (ch == NULL) in channel_remove()
209 strncpy(chid, ch->id, CTCM_ID_SIZE); in channel_remove()
211 channel_free(ch); in channel_remove()
213 if (*c == ch) { in channel_remove()
214 *c = ch->next; in channel_remove()
215 fsm_deltimer(&ch->timer); in channel_remove()
216 if (IS_MPC(ch)) in channel_remove()
217 fsm_deltimer(&ch->sweep_timer); in channel_remove()
219 kfree_fsm(ch->fsm); in channel_remove()
220 clear_normalized_cda(&ch->ccw[4]); in channel_remove()
221 if (ch->trans_skb != NULL) { in channel_remove()
222 clear_normalized_cda(&ch->ccw[1]); in channel_remove()
223 dev_kfree_skb_any(ch->trans_skb); in channel_remove()
225 if (IS_MPC(ch)) { in channel_remove()
226 tasklet_kill(&ch->ch_tasklet); in channel_remove()
227 tasklet_kill(&ch->ch_disc_tasklet); in channel_remove()
228 kfree(ch->discontact_th); in channel_remove()
230 kfree(ch->ccw); in channel_remove()
231 kfree(ch->irb); in channel_remove()
232 kfree(ch); in channel_remove()
255 struct channel *ch = channels; in channel_get() local
257 while (ch && (strncmp(ch->id, id, CTCM_ID_SIZE) || (ch->type != type))) in channel_get()
258 ch = ch->next; in channel_get()
259 if (!ch) { in channel_get()
264 if (ch->flags & CHANNEL_FLAGS_INUSE) in channel_get()
265 ch = NULL; in channel_get()
267 ch->flags |= CHANNEL_FLAGS_INUSE; in channel_get()
268 ch->flags &= ~CHANNEL_FLAGS_RWMASK; in channel_get()
269 ch->flags |= (direction == CTCM_WRITE) in channel_get()
271 fsm_newstate(ch->fsm, CTC_STATE_STOPPED); in channel_get()
274 return ch; in channel_get()
306 * ch The channel, the sense code belongs to.
309 static void ccw_unit_check(struct channel *ch, __u8 sense) in ccw_unit_check() argument
313 CTCM_FUNTAIL, ch->id, sense); in ccw_unit_check()
317 if (ch->sense_rc != 0x01) { in ccw_unit_check()
320 "disconnected\n", ch->id); in ccw_unit_check()
321 ch->sense_rc = 0x01; in ccw_unit_check()
323 fsm_event(ch->fsm, CTC_EVENT_UC_RCRESET, ch); in ccw_unit_check()
325 if (ch->sense_rc != SNS0_INTERVENTION_REQ) { in ccw_unit_check()
328 "not available\n", ch->id); in ccw_unit_check()
329 ch->sense_rc = SNS0_INTERVENTION_REQ; in ccw_unit_check()
331 fsm_event(ch->fsm, CTC_EVENT_UC_RSRESET, ch); in ccw_unit_check()
335 if (ch->sense_rc != SNS0_BUS_OUT_CHECK) { in ccw_unit_check()
338 CTCM_FUNTAIL, ch->id, sense); in ccw_unit_check()
339 ch->sense_rc = SNS0_BUS_OUT_CHECK; in ccw_unit_check()
341 fsm_event(ch->fsm, CTC_EVENT_UC_HWFAIL, ch); in ccw_unit_check()
343 if (ch->sense_rc != SNS0_EQUIPMENT_CHECK) { in ccw_unit_check()
346 CTCM_FUNTAIL, ch->id, sense); in ccw_unit_check()
347 ch->sense_rc = SNS0_EQUIPMENT_CHECK; in ccw_unit_check()
349 fsm_event(ch->fsm, CTC_EVENT_UC_RXPARITY, ch); in ccw_unit_check()
352 if (ch->sense_rc != SNS0_BUS_OUT_CHECK) { in ccw_unit_check()
355 CTCM_FUNTAIL, ch->id, sense); in ccw_unit_check()
356 ch->sense_rc = SNS0_BUS_OUT_CHECK; in ccw_unit_check()
359 fsm_event(ch->fsm, CTC_EVENT_UC_TXTIMEOUT, ch); in ccw_unit_check()
361 fsm_event(ch->fsm, CTC_EVENT_UC_TXPARITY, ch); in ccw_unit_check()
363 if (ch->sense_rc != SNS0_CMD_REJECT) { in ccw_unit_check()
366 CTCM_FUNTAIL, ch->id); in ccw_unit_check()
367 ch->sense_rc = SNS0_CMD_REJECT; in ccw_unit_check()
372 CTCM_FUNTAIL, ch->id); in ccw_unit_check()
373 fsm_event(ch->fsm, CTC_EVENT_UC_ZERO, ch); in ccw_unit_check()
377 CTCM_FUNTAIL, ch->id, sense); in ccw_unit_check()
378 fsm_event(ch->fsm, CTC_EVENT_UC_UNKNOWN, ch); in ccw_unit_check()
382 int ctcm_ch_alloc_buffer(struct channel *ch) in ctcm_ch_alloc_buffer() argument
384 clear_normalized_cda(&ch->ccw[1]); in ctcm_ch_alloc_buffer()
385 ch->trans_skb = __dev_alloc_skb(ch->max_bufsize, GFP_ATOMIC | GFP_DMA); in ctcm_ch_alloc_buffer()
386 if (ch->trans_skb == NULL) { in ctcm_ch_alloc_buffer()
389 CTCM_FUNTAIL, ch->id, in ctcm_ch_alloc_buffer()
390 (CHANNEL_DIRECTION(ch->flags) == CTCM_READ) ? in ctcm_ch_alloc_buffer()
395 ch->ccw[1].count = ch->max_bufsize; in ctcm_ch_alloc_buffer()
396 if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) { in ctcm_ch_alloc_buffer()
397 dev_kfree_skb(ch->trans_skb); in ctcm_ch_alloc_buffer()
398 ch->trans_skb = NULL; in ctcm_ch_alloc_buffer()
401 CTCM_FUNTAIL, ch->id, in ctcm_ch_alloc_buffer()
402 (CHANNEL_DIRECTION(ch->flags) == CTCM_READ) ? in ctcm_ch_alloc_buffer()
407 ch->ccw[1].count = 0; in ctcm_ch_alloc_buffer()
408 ch->trans_skb_data = ch->trans_skb->data; in ctcm_ch_alloc_buffer()
409 ch->flags &= ~CHANNEL_FLAGS_BUFSIZE_CHANGED; in ctcm_ch_alloc_buffer()
458 * ch Channel to be used for sending.
465 static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) in ctcm_transmit_skb() argument
479 spin_lock_irqsave(&ch->collect_lock, saveflags); in ctcm_transmit_skb()
480 if (fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) { in ctcm_transmit_skb()
483 if (ch->collect_len + l > ch->max_bufsize - 2) { in ctcm_transmit_skb()
484 spin_unlock_irqrestore(&ch->collect_lock, saveflags); in ctcm_transmit_skb()
493 skb_queue_tail(&ch->collect_queue, skb); in ctcm_transmit_skb()
494 ch->collect_len += l; in ctcm_transmit_skb()
496 spin_unlock_irqrestore(&ch->collect_lock, saveflags); in ctcm_transmit_skb()
499 spin_unlock_irqrestore(&ch->collect_lock, saveflags); in ctcm_transmit_skb()
505 ch->prof.txlen += skb->len; in ctcm_transmit_skb()
523 ctcm_clear_busy(ch->netdev); in ctcm_transmit_skb()
534 ch->ccw[4].count = block_len; in ctcm_transmit_skb()
535 if (set_normalized_cda(&ch->ccw[4], skb->data)) { in ctcm_transmit_skb()
541 if (ctcm_checkalloc_buffer(ch)) { in ctcm_transmit_skb()
548 ctcm_clear_busy(ch->netdev); in ctcm_transmit_skb()
552 skb_reset_tail_pointer(ch->trans_skb); in ctcm_transmit_skb()
553 ch->trans_skb->len = 0; in ctcm_transmit_skb()
554 ch->ccw[1].count = skb->len; in ctcm_transmit_skb()
556 skb_put(ch->trans_skb, skb->len), skb->len); in ctcm_transmit_skb()
561 skb_queue_tail(&ch->io_queue, skb); in ctcm_transmit_skb()
565 ctcmpc_dumpit((char *)&ch->ccw[ccw_idx], in ctcm_transmit_skb()
567 ch->retry = 0; in ctcm_transmit_skb()
568 fsm_newstate(ch->fsm, CTC_STATE_TX); in ctcm_transmit_skb()
569 fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); in ctcm_transmit_skb()
570 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); in ctcm_transmit_skb()
571 ch->prof.send_stamp = jiffies; in ctcm_transmit_skb()
572 rc = ccw_device_start(ch->cdev, &ch->ccw[ccw_idx], 0, 0xff, 0); in ctcm_transmit_skb()
573 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags); in ctcm_transmit_skb()
575 ch->prof.doios_single++; in ctcm_transmit_skb()
577 fsm_deltimer(&ch->timer); in ctcm_transmit_skb()
578 ctcm_ccw_check_rc(ch, rc, "single skb TX"); in ctcm_transmit_skb()
580 skb_dequeue_tail(&ch->io_queue); in ctcm_transmit_skb()
587 struct net_device *dev = ch->netdev; in ctcm_transmit_skb()
593 ctcm_clear_busy(ch->netdev); in ctcm_transmit_skb()
604 struct channel *ch; in ctcmpc_send_sweep_req() local
609 ch = priv->channel[CTCM_WRITE]; in ctcmpc_send_sweep_req()
628 header->sw.th_last_seq = ch->th_seq_num; in ctcmpc_send_sweep_req()
631 skb_queue_tail(&ch->sweep_queue, sweep_skb); in ctcmpc_send_sweep_req()
633 fsm_addtimer(&ch->sweep_timer, 100, CTC_EVENT_RSWEEP_TIMER, ch); in ctcmpc_send_sweep_req()
648 static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) in ctcmpc_transmit_skb() argument
651 struct net_device *dev = ch->netdev; in ctcmpc_transmit_skb()
661 CTCM_PR_DEBUG("Enter %s: %s, cp=%i ch=0x%p id=%s state=%s\n", in ctcmpc_transmit_skb()
662 __func__, dev->name, smp_processor_id(), ch, in ctcmpc_transmit_skb()
663 ch->id, fsm_getstate_str(ch->fsm)); in ctcmpc_transmit_skb()
665 if ((fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) || grp->in_sweep) { in ctcmpc_transmit_skb()
666 spin_lock_irqsave(&ch->collect_lock, saveflags); in ctcmpc_transmit_skb()
684 skb_queue_tail(&ch->collect_queue, skb); in ctcmpc_transmit_skb()
685 ch->collect_len += skb->len; in ctcmpc_transmit_skb()
687 spin_unlock_irqrestore(&ch->collect_lock, saveflags); in ctcmpc_transmit_skb()
725 if (ch->collect_len > 0) { in ctcmpc_transmit_skb()
726 spin_lock_irqsave(&ch->collect_lock, saveflags); in ctcmpc_transmit_skb()
727 skb_queue_tail(&ch->collect_queue, skb); in ctcmpc_transmit_skb()
728 ch->collect_len += skb->len; in ctcmpc_transmit_skb()
729 skb = skb_dequeue(&ch->collect_queue); in ctcmpc_transmit_skb()
730 ch->collect_len -= skb->len; in ctcmpc_transmit_skb()
731 spin_unlock_irqrestore(&ch->collect_lock, saveflags); in ctcmpc_transmit_skb()
737 ch->prof.txlen += skb->len - PDU_HEADER_LENGTH; in ctcmpc_transmit_skb()
744 ch->th_seq_num++; in ctcmpc_transmit_skb()
745 header->th_seq_num = ch->th_seq_num; in ctcmpc_transmit_skb()
748 __func__, dev->name, ch->th_seq_num); in ctcmpc_transmit_skb()
755 ch->ccw[4].count = skb->len; in ctcmpc_transmit_skb()
756 if (set_normalized_cda(&ch->ccw[4], skb->data)) { in ctcmpc_transmit_skb()
761 if (ctcm_checkalloc_buffer(ch)) { in ctcmpc_transmit_skb()
769 skb_reset_tail_pointer(ch->trans_skb); in ctcmpc_transmit_skb()
770 ch->trans_skb->len = 0; in ctcmpc_transmit_skb()
771 ch->ccw[1].count = skb->len; in ctcmpc_transmit_skb()
772 skb_put_data(ch->trans_skb, skb->data, skb->len); in ctcmpc_transmit_skb()
778 __func__, dev->name, ch->trans_skb->len); in ctcmpc_transmit_skb()
779 CTCM_D3_DUMP((char *)ch->trans_skb->data, in ctcmpc_transmit_skb()
780 min_t(int, 32, ch->trans_skb->len)); in ctcmpc_transmit_skb()
782 skb_queue_tail(&ch->io_queue, skb); in ctcmpc_transmit_skb()
785 ch->retry = 0; in ctcmpc_transmit_skb()
786 fsm_newstate(ch->fsm, CTC_STATE_TX); in ctcmpc_transmit_skb()
787 fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); in ctcmpc_transmit_skb()
790 ctcmpc_dumpit((char *)&ch->ccw[ccw_idx], in ctcmpc_transmit_skb()
793 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); in ctcmpc_transmit_skb()
794 ch->prof.send_stamp = jiffies; in ctcmpc_transmit_skb()
795 rc = ccw_device_start(ch->cdev, &ch->ccw[ccw_idx], 0, 0xff, 0); in ctcmpc_transmit_skb()
796 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags); in ctcmpc_transmit_skb()
798 ch->prof.doios_single++; in ctcmpc_transmit_skb()
800 fsm_deltimer(&ch->timer); in ctcmpc_transmit_skb()
801 ctcm_ccw_check_rc(ch, rc, "single skb TX"); in ctcmpc_transmit_skb()
803 skb_dequeue_tail(&ch->io_queue); in ctcmpc_transmit_skb()
808 if (ch->th_seq_num > 0xf0000000) /* Chose at random. */ in ctcmpc_transmit_skb()
809 ctcmpc_send_sweep_req(ch); in ctcmpc_transmit_skb()
815 CTCM_FUNTAIL, ch->id); in ctcmpc_transmit_skb()
1150 struct channel *ch; in ctcm_irq_handler() local
1182 ch = priv->channel[CTCM_READ]; in ctcm_irq_handler()
1184 ch = priv->channel[CTCM_WRITE]; in ctcm_irq_handler()
1194 dev = ch->netdev; in ctcm_irq_handler()
1197 "%s Internal error: net_device is NULL, ch = 0x%p\n", in ctcm_irq_handler()
1198 __func__, ch); in ctcm_irq_handler()
1204 memcpy(ch->irb, irb, sizeof(struct irb)); in ctcm_irq_handler()
1208 fsm_event(ch->fsm, CTC_EVENT_SC_UNKNOWN, ch); in ctcm_irq_handler()
1210 "%s(%s): sub-ch check %s: cs=%02x ds=%02x", in ctcm_irq_handler()
1211 CTCM_FUNTAIL, dev->name, ch->id, cstat, dstat); in ctcm_irq_handler()
1219 if ((irb->ecw[0] & ch->sense_rc) == 0) in ctcm_irq_handler()
1223 CTCM_FUNTAIL, ch->id, irb->ecw[0], dstat); in ctcm_irq_handler()
1224 ccw_unit_check(ch, irb->ecw[0]); in ctcm_irq_handler()
1229 fsm_event(ch->fsm, CTC_EVENT_ATTNBUSY, ch); in ctcm_irq_handler()
1231 fsm_event(ch->fsm, CTC_EVENT_BUSY, ch); in ctcm_irq_handler()
1235 fsm_event(ch->fsm, CTC_EVENT_ATTN, ch); in ctcm_irq_handler()
1242 fsm_event(ch->fsm, CTC_EVENT_FINSTAT, ch); in ctcm_irq_handler()
1244 fsm_event(ch->fsm, CTC_EVENT_IRQ, ch); in ctcm_irq_handler()
1303 struct channel *ch; in add_channel() local
1311 ch = kzalloc(sizeof(struct channel), GFP_KERNEL); in add_channel()
1312 if (ch == NULL) in add_channel()
1315 ch->protocol = priv->protocol; in add_channel()
1317 ch->discontact_th = kzalloc(TH_HEADER_LENGTH, GFP_KERNEL); in add_channel()
1318 if (ch->discontact_th == NULL) in add_channel()
1321 ch->discontact_th->th_blk_flag = TH_DISCONTACT; in add_channel()
1322 tasklet_init(&ch->ch_disc_tasklet, in add_channel()
1323 mpc_action_send_discontact, (unsigned long)ch); in add_channel()
1325 tasklet_init(&ch->ch_tasklet, ctcmpc_bh, (unsigned long)ch); in add_channel()
1326 ch->max_bufsize = (MPC_BUFSIZE_DEFAULT - 35); in add_channel()
1331 ch->ccw = kcalloc(ccw_num, sizeof(struct ccw1), GFP_KERNEL | GFP_DMA); in add_channel()
1332 if (ch->ccw == NULL) in add_channel()
1335 ch->cdev = cdev; in add_channel()
1336 scnprintf(ch->id, CTCM_ID_SIZE, "ch-%s", dev_name(&cdev->dev)); in add_channel()
1337 ch->type = type; in add_channel()
1355 * ch->ccw[0..5] are initialized in ch_action_start because in add_channel()
1359 * ch-ccw[8-14] need to be used for the XID exchange either in add_channel()
1382 ch->ccw[6].cmd_code = CCW_CMD_SET_EXTENDED; in add_channel()
1383 ch->ccw[6].flags = CCW_FLAG_SLI; in add_channel()
1385 ch->ccw[7].cmd_code = CCW_CMD_NOOP; in add_channel()
1386 ch->ccw[7].flags = CCW_FLAG_SLI; in add_channel()
1389 ch->ccw[15].cmd_code = CCW_CMD_WRITE; in add_channel()
1390 ch->ccw[15].flags = CCW_FLAG_SLI | CCW_FLAG_CC; in add_channel()
1391 ch->ccw[15].count = TH_HEADER_LENGTH; in add_channel()
1392 ch->ccw[15].cda = virt_to_phys(ch->discontact_th); in add_channel()
1394 ch->ccw[16].cmd_code = CCW_CMD_NOOP; in add_channel()
1395 ch->ccw[16].flags = CCW_FLAG_SLI; in add_channel()
1397 ch->fsm = init_fsm(ch->id, ctc_ch_state_names, in add_channel()
1402 ch->fsm = init_fsm(ch->id, ctc_ch_state_names, in add_channel()
1407 if (ch->fsm == NULL) in add_channel()
1410 fsm_newstate(ch->fsm, CTC_STATE_IDLE); in add_channel()
1412 ch->irb = kzalloc(sizeof(struct irb), GFP_KERNEL); in add_channel()
1413 if (ch->irb == NULL) in add_channel()
1416 while (*c && ctcm_less_than((*c)->id, ch->id)) in add_channel()
1419 if (*c && (!strncmp((*c)->id, ch->id, CTCM_ID_SIZE))) { in add_channel()
1427 spin_lock_init(&ch->collect_lock); in add_channel()
1429 fsm_settimer(ch->fsm, &ch->timer); in add_channel()
1430 skb_queue_head_init(&ch->io_queue); in add_channel()
1431 skb_queue_head_init(&ch->collect_queue); in add_channel()
1434 fsm_settimer(ch->fsm, &ch->sweep_timer); in add_channel()
1435 skb_queue_head_init(&ch->sweep_queue); in add_channel()
1437 ch->next = *c; in add_channel()
1438 *c = ch; in add_channel()
1445 kfree(ch->ccw); in add_channel()
1446 kfree(ch->discontact_th); in add_channel()
1447 kfree_fsm(ch->fsm); in add_channel()
1448 kfree(ch->irb); in add_channel()
1449 kfree(ch); in add_channel()
1501 scnprintf(read_id, CTCM_ID_SIZE, "ch-%s", dev_name(&cdev0->dev)); in ctcm_new_device()
1502 scnprintf(write_id, CTCM_ID_SIZE, "ch-%s", dev_name(&cdev1->dev)); in ctcm_new_device()