Lines Matching +full:version +full:- +full:minor

1 // SPDX-License-Identifier: GPL-2.0
22 err = -EINVAL; in vio_ldc_send()
23 while (limit-- > 0) { in vio_ldc_send()
24 err = ldc_write(vio->lp, data, len); in vio_ldc_send()
25 if (!err || (err != -EAGAIN)) in vio_ldc_send()
37 tag->sid = vio_send_sid(vio); in send_ctrl()
43 tag->type = type; in init_tag()
44 tag->stype = stype; in init_tag()
45 tag->stype_env = stype_env; in init_tag()
48 static int send_version(struct vio_driver_state *vio, u16 major, u16 minor) in send_version() argument
52 vio->_local_sid = (u32) sched_clock(); in send_version()
57 pkt.minor = minor; in send_version()
58 pkt.dev_class = vio->dev_class; in send_version()
60 viodbg(HS, "SEND VERSION INFO maj[%u] min[%u] devclass[%u]\n", in send_version()
61 major, minor, vio->dev_class); in send_version()
72 vio->hs_state = VIO_HS_INVALID; in start_handshake()
75 vio->ver_table[0].major, in start_handshake()
76 vio->ver_table[0].minor); in start_handshake()
88 BUG_ON(!(vio->dr_state & VIO_DR_STATE_RXREG)); in flush_rx_dring()
90 dr = &vio->drings[VIO_DRIVER_RX_RING]; in flush_rx_dring()
91 ident = dr->ident; in flush_rx_dring()
93 BUG_ON(!vio->desc_buf); in flush_rx_dring()
94 kfree(vio->desc_buf); in flush_rx_dring()
95 vio->desc_buf = NULL; in flush_rx_dring()
98 dr->ident = ident; in flush_rx_dring()
104 vio->hs_state = VIO_HS_INVALID; in vio_link_state_change()
106 switch (vio->dev_class) { in vio_link_state_change()
109 vio->dr_state = (VIO_DR_STATE_TXREQ | in vio_link_state_change()
114 vio->dr_state = VIO_DR_STATE_TXREQ; in vio_link_state_change()
117 vio->dr_state = VIO_DR_STATE_RXREQ; in vio_link_state_change()
122 vio->hs_state = VIO_HS_INVALID; in vio_link_state_change()
124 if (vio->dr_state & VIO_DR_STATE_RXREG) in vio_link_state_change()
127 vio->dr_state = 0x00; in vio_link_state_change()
128 memset(&vio->ver, 0, sizeof(vio->ver)); in vio_link_state_change()
130 ldc_disconnect(vio->lp); in vio_link_state_change()
146 vio->dr_state &= ~(VIO_DR_STATE_TXREG | in handshake_failure()
149 dr = &vio->drings[VIO_DRIVER_RX_RING]; in handshake_failure()
152 kfree(vio->desc_buf); in handshake_failure()
153 vio->desc_buf = NULL; in handshake_failure()
154 vio->desc_buf_len = 0; in handshake_failure()
156 vio->hs_state = VIO_HS_INVALID; in handshake_failure()
158 return -ECONNRESET; in handshake_failure()
166 pkt->type, pkt->stype, pkt->stype_env, pkt->sid); in process_unknown()
169 vio->vdev->channel_id); in process_unknown()
171 ldc_disconnect(vio->lp); in process_unknown()
173 return -ECONNRESET; in process_unknown()
178 struct vio_dring_state *dr = &vio->drings[VIO_DRIVER_TX_RING]; in send_dreg()
187 dr->ncookies); in send_dreg()
191 return -EINVAL; in send_dreg()
196 u.pkt.num_descr = dr->num_entries; in send_dreg()
197 u.pkt.descr_size = dr->entry_size; in send_dreg()
199 u.pkt.num_cookies = dr->ncookies; in send_dreg()
206 for (i = 0; i < dr->ncookies; i++) { in send_dreg()
207 u.pkt.cookies[i] = dr->cookies[i]; in send_dreg()
233 if (!vio->ops) in send_attr()
234 return -EINVAL; in send_attr()
236 return vio->ops->send_attr(vio); in send_attr()
245 for (i = 0; i < vio->ver_table_entries; i++) { in find_by_major()
246 struct vio_version *v = &vio->ver_table[i]; in find_by_major()
247 if (v->major <= major) { in find_by_major()
261 viodbg(HS, "GOT VERSION INFO maj[%u] min[%u] devclass[%u]\n", in process_ver_info()
262 pkt->major, pkt->minor, pkt->dev_class); in process_ver_info()
264 if (vio->hs_state != VIO_HS_INVALID) { in process_ver_info()
266 memset(&vio->ver, 0, sizeof(vio->ver)); in process_ver_info()
267 vio->hs_state = VIO_HS_INVALID; in process_ver_info()
270 vap = find_by_major(vio, pkt->major); in process_ver_info()
272 vio->_peer_sid = pkt->tag.sid; in process_ver_info()
275 pkt->tag.stype = VIO_SUBTYPE_NACK; in process_ver_info()
276 pkt->major = 0; in process_ver_info()
277 pkt->minor = 0; in process_ver_info()
278 viodbg(HS, "SEND VERSION NACK maj[0] min[0]\n"); in process_ver_info()
279 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt)); in process_ver_info()
280 } else if (vap->major != pkt->major) { in process_ver_info()
281 pkt->tag.stype = VIO_SUBTYPE_NACK; in process_ver_info()
282 pkt->major = vap->major; in process_ver_info()
283 pkt->minor = vap->minor; in process_ver_info()
284 viodbg(HS, "SEND VERSION NACK maj[%u] min[%u]\n", in process_ver_info()
285 pkt->major, pkt->minor); in process_ver_info()
286 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt)); in process_ver_info()
289 .major = pkt->major, in process_ver_info()
290 .minor = pkt->minor, in process_ver_info()
292 if (ver.minor > vap->minor) in process_ver_info()
293 ver.minor = vap->minor; in process_ver_info()
294 pkt->minor = ver.minor; in process_ver_info()
295 pkt->tag.stype = VIO_SUBTYPE_ACK; in process_ver_info()
296 pkt->dev_class = vio->dev_class; in process_ver_info()
297 viodbg(HS, "SEND VERSION ACK maj[%u] min[%u]\n", in process_ver_info()
298 pkt->major, pkt->minor); in process_ver_info()
299 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt)); in process_ver_info()
301 vio->ver = ver; in process_ver_info()
302 vio->hs_state = VIO_HS_GOTVERS; in process_ver_info()
314 viodbg(HS, "GOT VERSION ACK maj[%u] min[%u] devclass[%u]\n", in process_ver_ack()
315 pkt->major, pkt->minor, pkt->dev_class); in process_ver_ack()
317 if (vio->hs_state & VIO_HS_GOTVERS) { in process_ver_ack()
318 if (vio->ver.major != pkt->major || in process_ver_ack()
319 vio->ver.minor != pkt->minor) { in process_ver_ack()
320 pkt->tag.stype = VIO_SUBTYPE_NACK; in process_ver_ack()
321 (void) send_ctrl(vio, &pkt->tag, sizeof(*pkt)); in process_ver_ack()
325 vio->ver.major = pkt->major; in process_ver_ack()
326 vio->ver.minor = pkt->minor; in process_ver_ack()
327 vio->hs_state = VIO_HS_GOTVERS; in process_ver_ack()
330 switch (vio->dev_class) { in process_ver_ack()
349 viodbg(HS, "GOT VERSION NACK maj[%u] min[%u] devclass[%u]\n", in process_ver_nack()
350 pkt->major, pkt->minor, pkt->dev_class); in process_ver_nack()
352 if (pkt->major == 0 && pkt->minor == 0) in process_ver_nack()
354 nver = find_by_major(vio, pkt->major); in process_ver_nack()
358 if (send_version(vio, nver->major, nver->minor) < 0) in process_ver_nack()
366 switch (pkt->tag.stype) { in process_ver()
385 if (!(vio->hs_state & VIO_HS_GOTVERS)) in process_attr()
388 if (!vio->ops) in process_attr()
391 err = vio->ops->handle_attr(vio, pkt); in process_attr()
395 vio->hs_state |= VIO_HS_GOT_ATTR; in process_attr()
397 if ((vio->dr_state & VIO_DR_STATE_TXREQ) && in process_attr()
398 !(vio->hs_state & VIO_HS_SENT_DREG)) { in process_attr()
402 vio->hs_state |= VIO_HS_SENT_DREG; in process_attr()
413 need_rx = (vio->dr_state & VIO_DR_STATE_RXREQ); in all_drings_registered()
414 need_tx = (vio->dr_state & VIO_DR_STATE_TXREQ); in all_drings_registered()
417 !(vio->dr_state & VIO_DR_STATE_RXREG)) in all_drings_registered()
421 !(vio->dr_state & VIO_DR_STATE_TXREG)) in all_drings_registered()
435 (unsigned long long) pkt->dring_ident, in process_dreg_info()
436 pkt->num_descr, pkt->descr_size, pkt->options, in process_dreg_info()
437 pkt->num_cookies); in process_dreg_info()
439 if (!(vio->dr_state & VIO_DR_STATE_RXREQ)) in process_dreg_info()
442 if (vio->dr_state & VIO_DR_STATE_RXREG) in process_dreg_info()
447 if (!(pkt->options & VIO_TX_DRING)) in process_dreg_info()
449 pkt->options = VIO_TX_DRING; in process_dreg_info()
452 BUG_ON(vio->desc_buf); in process_dreg_info()
454 vio->desc_buf = kzalloc(pkt->descr_size, GFP_ATOMIC); in process_dreg_info()
455 if (!vio->desc_buf) in process_dreg_info()
458 vio->desc_buf_len = pkt->descr_size; in process_dreg_info()
460 dr = &vio->drings[VIO_DRIVER_RX_RING]; in process_dreg_info()
462 dr->num_entries = pkt->num_descr; in process_dreg_info()
463 dr->entry_size = pkt->descr_size; in process_dreg_info()
464 dr->ncookies = pkt->num_cookies; in process_dreg_info()
465 for (i = 0; i < dr->ncookies; i++) { in process_dreg_info()
466 dr->cookies[i] = pkt->cookies[i]; in process_dreg_info()
471 pkt->cookies[i].cookie_addr, in process_dreg_info()
473 pkt->cookies[i].cookie_size); in process_dreg_info()
476 pkt->tag.stype = VIO_SUBTYPE_ACK; in process_dreg_info()
477 pkt->dring_ident = ++dr->ident; in process_dreg_info()
481 (unsigned long long) pkt->dring_ident, in process_dreg_info()
482 pkt->num_descr, pkt->descr_size, pkt->options, in process_dreg_info()
483 pkt->num_cookies); in process_dreg_info()
485 if (send_ctrl(vio, &pkt->tag, struct_size(pkt, cookies, dr->ncookies)) < 0) in process_dreg_info()
488 vio->dr_state |= VIO_DR_STATE_RXREG; in process_dreg_info()
493 pkt->tag.stype = VIO_SUBTYPE_NACK; in process_dreg_info()
495 (void) send_ctrl(vio, &pkt->tag, sizeof(*pkt)); in process_dreg_info()
507 (unsigned long long) pkt->dring_ident, in process_dreg_ack()
508 pkt->num_descr, pkt->descr_size, pkt->options, in process_dreg_ack()
509 pkt->num_cookies); in process_dreg_ack()
511 dr = &vio->drings[VIO_DRIVER_TX_RING]; in process_dreg_ack()
513 if (!(vio->dr_state & VIO_DR_STATE_TXREQ)) in process_dreg_ack()
516 dr->ident = pkt->dring_ident; in process_dreg_ack()
517 vio->dr_state |= VIO_DR_STATE_TXREG; in process_dreg_ack()
522 vio->hs_state = VIO_HS_SENT_RDX; in process_dreg_ack()
532 (unsigned long long) pkt->dring_ident, in process_dreg_nack()
533 pkt->num_descr, pkt->descr_size, pkt->options, in process_dreg_nack()
534 pkt->num_cookies); in process_dreg_nack()
542 if (!(vio->hs_state & VIO_HS_GOTVERS)) in process_dreg()
545 switch (pkt->tag.stype) { in process_dreg()
563 struct vio_dring_state *dr = &vio->drings[VIO_DRIVER_RX_RING]; in process_dunreg()
567 if (pkt->dring_ident != dr->ident) in process_dunreg()
570 vio->dr_state &= ~VIO_DR_STATE_RXREG; in process_dunreg()
574 kfree(vio->desc_buf); in process_dunreg()
575 vio->desc_buf = NULL; in process_dunreg()
576 vio->desc_buf_len = 0; in process_dunreg()
585 pkt->tag.stype = VIO_SUBTYPE_ACK; in process_rdx_info()
587 if (send_ctrl(vio, &pkt->tag, sizeof(*pkt)) < 0) in process_rdx_info()
590 vio->hs_state |= VIO_HS_SENT_RDX_ACK; in process_rdx_info()
598 if (!(vio->hs_state & VIO_HS_SENT_RDX)) in process_rdx_ack()
601 vio->hs_state |= VIO_HS_GOT_RDX_ACK; in process_rdx_ack()
617 switch (pkt->tag.stype) { in process_rdx()
635 u8 prev_state = vio->hs_state; in vio_control_pkt_engine()
638 switch (tag->stype_env) { in vio_control_pkt_engine()
665 vio->hs_state != prev_state && in vio_control_pkt_engine()
666 (vio->hs_state & VIO_HS_COMPLETE)) { in vio_control_pkt_engine()
667 if (vio->ops) in vio_control_pkt_engine()
668 vio->ops->handshake_complete(vio); in vio_control_pkt_engine()
689 /* Always let VERSION+INFO packets through unchecked, they in vio_validate_sid()
692 if (tp->type == VIO_TYPE_CTRL && in vio_validate_sid()
693 tp->stype == VIO_SUBTYPE_INFO && in vio_validate_sid()
694 tp->stype_env == VIO_VER_INFO) in vio_validate_sid()
698 switch (vio->dev_class) { in vio_validate_sid()
703 sid = vio->_peer_sid; in vio_validate_sid()
707 sid = vio->_local_sid; in vio_validate_sid()
711 if (sid == tp->sid) in vio_validate_sid()
713 viodbg(DATA, "BAD SID tag->sid[%08x] peer_sid[%08x] local_sid[%08x]\n", in vio_validate_sid()
714 tp->sid, vio->_peer_sid, vio->_local_sid); in vio_validate_sid()
715 return -EINVAL; in vio_validate_sid()
721 switch (vio->dev_class) { in vio_send_sid()
726 return vio->_local_sid; in vio_send_sid()
729 return vio->_peer_sid; in vio_send_sid()
741 cfg.tx_irq = vio->vdev->tx_irq; in vio_ldc_alloc()
742 cfg.rx_irq = vio->vdev->rx_irq; in vio_ldc_alloc()
744 lp = ldc_alloc(vio->vdev->channel_id, &cfg, event_arg, vio->name); in vio_ldc_alloc()
748 vio->lp = lp; in vio_ldc_alloc()
756 ldc_free(vio->lp); in vio_ldc_free()
757 vio->lp = NULL; in vio_ldc_free()
759 kfree(vio->desc_buf); in vio_ldc_free()
760 vio->desc_buf = NULL; in vio_ldc_free()
761 vio->desc_buf_len = 0; in vio_ldc_free()
770 spin_lock_irqsave(&vio->lock, flags); in vio_port_up()
772 state = ldc_state(vio->lp); in vio_port_up()
776 err = ldc_bind(vio->lp); in vio_port_up()
780 vio->name, vio->vdev->channel_id, err); in vio_port_up()
784 if (ldc_mode(vio->lp) == LDC_MODE_RAW) in vio_port_up()
785 ldc_set_state(vio->lp, LDC_STATE_CONNECTED); in vio_port_up()
787 err = ldc_connect(vio->lp); in vio_port_up()
792 vio->name, vio->vdev->channel_id, err); in vio_port_up()
798 mod_timer(&vio->timer, expires); in vio_port_up()
801 spin_unlock_irqrestore(&vio->lock, flags); in vio_port_up()
826 return -EINVAL; in vio_driver_init()
833 if (!ops || !ops->send_attr || !ops->handle_attr || in vio_driver_init()
834 !ops->handshake_complete) in vio_driver_init()
835 return -EINVAL; in vio_driver_init()
839 return -EINVAL; in vio_driver_init()
842 return -EINVAL; in vio_driver_init()
844 spin_lock_init(&vio->lock); in vio_driver_init()
846 vio->name = name; in vio_driver_init()
848 vio->dev_class = dev_class; in vio_driver_init()
849 vio->vdev = vdev; in vio_driver_init()
851 vio->ver_table = ver_table; in vio_driver_init()
852 vio->ver_table_entries = ver_table_size; in vio_driver_init()
854 vio->ops = ops; in vio_driver_init()
856 timer_setup(&vio->timer, vio_port_timer, 0); in vio_driver_init()