Lines Matching defs:ch

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