• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/arch/sparc/kernel/

Lines Matching refs:vio

14 #include <asm/vio.h>
16 int vio_ldc_send(struct vio_driver_state *vio, void *data, int len)
22 err = ldc_write(vio->lp, data, len);
32 static int send_ctrl(struct vio_driver_state *vio,
35 tag->sid = vio_send_sid(vio);
36 return vio_ldc_send(vio, tag, len);
46 static int send_version(struct vio_driver_state *vio, u16 major, u16 minor)
50 vio->_local_sid = (u32) sched_clock();
56 pkt.dev_class = vio->dev_class;
59 major, minor, vio->dev_class);
61 return send_ctrl(vio, &pkt.tag, sizeof(pkt));
64 static int start_handshake(struct vio_driver_state *vio)
70 vio->hs_state = VIO_HS_INVALID;
72 err = send_version(vio,
73 vio->ver_table[0].major,
74 vio->ver_table[0].minor);
81 static void flush_rx_dring(struct vio_driver_state *vio)
86 BUG_ON(!(vio->dr_state & VIO_DR_STATE_RXREG));
88 dr = &vio->drings[VIO_DRIVER_RX_RING];
91 BUG_ON(!vio->desc_buf);
92 kfree(vio->desc_buf);
93 vio->desc_buf = NULL;
99 void vio_link_state_change(struct vio_driver_state *vio, int event)
102 vio->hs_state = VIO_HS_INVALID;
104 switch (vio->dev_class) {
107 vio->dr_state = (VIO_DR_STATE_TXREQ |
112 vio->dr_state = VIO_DR_STATE_TXREQ;
115 vio->dr_state = VIO_DR_STATE_RXREQ;
118 start_handshake(vio);
120 vio->hs_state = VIO_HS_INVALID;
122 if (vio->dr_state & VIO_DR_STATE_RXREG)
123 flush_rx_dring(vio);
125 vio->dr_state = 0x00;
126 memset(&vio->ver, 0, sizeof(vio->ver));
128 ldc_disconnect(vio->lp);
133 static int handshake_failure(struct vio_driver_state *vio)
140 vio->dr_state &= ~(VIO_DR_STATE_TXREG |
143 dr = &vio->drings[VIO_DRIVER_RX_RING];
146 kfree(vio->desc_buf);
147 vio->desc_buf = NULL;
148 vio->desc_buf_len = 0;
150 vio->hs_state = VIO_HS_INVALID;
155 static int process_unknown(struct vio_driver_state *vio, void *arg)
162 printk(KERN_ERR "vio: ID[%lu] Resetting connection.\n",
163 vio->vdev->channel_id);
165 ldc_disconnect(vio->lp);
170 static int send_dreg(struct vio_driver_state *vio)
172 struct vio_dring_state *dr = &vio->drings[VIO_DRIVER_TX_RING];
203 return send_ctrl(vio, &u.pkt.tag, sizeof(u));
206 static int send_rdx(struct vio_driver_state *vio)
216 return send_ctrl(vio, &pkt.tag, sizeof(pkt));
219 static int send_attr(struct vio_driver_state *vio)
221 return vio->ops->send_attr(vio);
224 static struct vio_version *find_by_major(struct vio_driver_state *vio,
230 for (i = 0; i < vio->ver_table_entries; i++) {
231 struct vio_version *v = &vio->ver_table[i];
240 static int process_ver_info(struct vio_driver_state *vio,
249 if (vio->hs_state != VIO_HS_INVALID) {
250 memset(&vio->ver, 0, sizeof(vio->ver));
251 vio->hs_state = VIO_HS_INVALID;
254 vap = find_by_major(vio, pkt->major);
256 vio->_peer_sid = pkt->tag.sid;
263 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt));
270 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt));
282 err = send_ctrl(vio, &pkt->tag, sizeof(*pkt));
284 vio->ver = ver;
285 vio->hs_state = VIO_HS_GOTVERS;
289 return handshake_failure(vio);
294 static int process_ver_ack(struct vio_driver_state *vio,
300 if (vio->hs_state & VIO_HS_GOTVERS) {
301 if (vio->ver.major != pkt->major ||
302 vio->ver.minor != pkt->minor) {
304 (void) send_ctrl(vio, &pkt->tag, sizeof(*pkt));
305 return handshake_failure(vio);
308 vio->ver.major = pkt->major;
309 vio->ver.minor = pkt->minor;
310 vio->hs_state = VIO_HS_GOTVERS;
313 switch (vio->dev_class) {
316 if (send_attr(vio) < 0)
317 return handshake_failure(vio);
327 static int process_ver_nack(struct vio_driver_state *vio,
336 return handshake_failure(vio);
337 nver = find_by_major(vio, pkt->major);
339 return handshake_failure(vio);
341 if (send_version(vio, nver->major, nver->minor) < 0)
342 return handshake_failure(vio);
347 static int process_ver(struct vio_driver_state *vio, struct vio_ver_info *pkt)
351 return process_ver_info(vio, pkt);
354 return process_ver_ack(vio, pkt);
357 return process_ver_nack(vio, pkt);
360 return handshake_failure(vio);
364 static int process_attr(struct vio_driver_state *vio, void *pkt)
368 if (!(vio->hs_state & VIO_HS_GOTVERS))
369 return handshake_failure(vio);
371 err = vio->ops->handle_attr(vio, pkt);
373 return handshake_failure(vio);
375 vio->hs_state |= VIO_HS_GOT_ATTR;
377 if ((vio->dr_state & VIO_DR_STATE_TXREQ) &&
378 !(vio->hs_state & VIO_HS_SENT_DREG)) {
379 if (send_dreg(vio) < 0)
380 return handshake_failure(vio);
382 vio->hs_state |= VIO_HS_SENT_DREG;
388 static int all_drings_registered(struct vio_driver_state *vio)
392 need_rx = (vio->dr_state & VIO_DR_STATE_RXREQ);
393 need_tx = (vio->dr_state & VIO_DR_STATE_TXREQ);
396 !(vio->dr_state & VIO_DR_STATE_RXREG))
400 !(vio->dr_state & VIO_DR_STATE_TXREG))
406 static int process_dreg_info(struct vio_driver_state *vio,
418 if (!(vio->dr_state & VIO_DR_STATE_RXREQ))
421 if (vio->dr_state & VIO_DR_STATE_RXREG)
424 BUG_ON(vio->desc_buf);
426 vio->desc_buf = kzalloc(pkt->descr_size, GFP_ATOMIC);
427 if (!vio->desc_buf)
430 vio->desc_buf_len = pkt->descr_size;
432 dr = &vio->drings[VIO_DRIVER_RX_RING];
456 if (send_ctrl(vio, &pkt->tag, len) < 0)
459 vio->dr_state |= VIO_DR_STATE_RXREG;
466 (void) send_ctrl(vio, &pkt->tag, sizeof(*pkt));
468 return handshake_failure(vio);
471 static int process_dreg_ack(struct vio_driver_state *vio,
482 dr = &vio->drings[VIO_DRIVER_TX_RING];
484 if (!(vio->dr_state & VIO_DR_STATE_TXREQ))
485 return handshake_failure(vio);
488 vio->dr_state |= VIO_DR_STATE_TXREG;
490 if (all_drings_registered(vio)) {
491 if (send_rdx(vio) < 0)
492 return handshake_failure(vio);
493 vio->hs_state = VIO_HS_SENT_RDX;
498 static int process_dreg_nack(struct vio_driver_state *vio,
507 return handshake_failure(vio);
510 static int process_dreg(struct vio_driver_state *vio,
513 if (!(vio->hs_state & VIO_HS_GOTVERS))
514 return handshake_failure(vio);
518 return process_dreg_info(vio, pkt);
521 return process_dreg_ack(vio, pkt);
524 return process_dreg_nack(vio, pkt);
527 return handshake_failure(vio);
531 static int process_dunreg(struct vio_driver_state *vio,
534 struct vio_dring_state *dr = &vio->drings[VIO_DRIVER_RX_RING];
541 vio->dr_state &= ~VIO_DR_STATE_RXREG;
545 kfree(vio->desc_buf);
546 vio->desc_buf = NULL;
547 vio->desc_buf_len = 0;
552 static int process_rdx_info(struct vio_driver_state *vio, struct vio_rdx *pkt)
558 if (send_ctrl(vio, &pkt->tag, sizeof(*pkt)) < 0)
559 return handshake_failure(vio);
561 vio->hs_state |= VIO_HS_SENT_RDX_ACK;
565 static int process_rdx_ack(struct vio_driver_state *vio, struct vio_rdx *pkt)
569 if (!(vio->hs_state & VIO_HS_SENT_RDX))
570 return handshake_failure(vio);
572 vio->hs_state |= VIO_HS_GOT_RDX_ACK;
576 static int process_rdx_nack(struct vio_driver_state *vio, struct vio_rdx *pkt)
580 return handshake_failure(vio);
583 static int process_rdx(struct vio_driver_state *vio, struct vio_rdx *pkt)
585 if (!all_drings_registered(vio))
586 handshake_failure(vio);
590 return process_rdx_info(vio, pkt);
593 return process_rdx_ack(vio, pkt);
596 return process_rdx_nack(vio, pkt);
599 return handshake_failure(vio);
603 int vio_control_pkt_engine(struct vio_driver_state *vio, void *pkt)
606 u8 prev_state = vio->hs_state;
611 err = process_ver(vio, pkt);
615 err = process_attr(vio, pkt);
619 err = process_dreg(vio, pkt);
623 err = process_dunreg(vio, pkt);
627 err = process_rdx(vio, pkt);
631 err = process_unknown(vio, pkt);
635 vio->hs_state != prev_state &&
636 (vio->hs_state & VIO_HS_COMPLETE))
637 vio->ops->handshake_complete(vio);
643 void vio_conn_reset(struct vio_driver_state *vio)
648 int vio_validate_sid(struct vio_driver_state *vio, struct vio_msg_tag *tp)
661 switch (vio->dev_class) {
666 sid = vio->_peer_sid;
670 sid = vio->_local_sid;
677 tp->sid, vio->_peer_sid, vio->_local_sid);
682 u32 vio_send_sid(struct vio_driver_state *vio)
684 switch (vio->dev_class) {
689 return vio->_local_sid;
692 return vio->_peer_sid;
697 int vio_ldc_alloc(struct vio_driver_state *vio,
704 cfg.tx_irq = vio->vdev->tx_irq;
705 cfg.rx_irq = vio->vdev->rx_irq;
707 lp = ldc_alloc(vio->vdev->channel_id, &cfg, event_arg);
711 vio->lp = lp;
717 void vio_ldc_free(struct vio_driver_state *vio)
719 ldc_free(vio->lp);
720 vio->lp = NULL;
722 kfree(vio->desc_buf);
723 vio->desc_buf = NULL;
724 vio->desc_buf_len = 0;
728 void vio_port_up(struct vio_driver_state *vio)
733 spin_lock_irqsave(&vio->lock, flags);
735 state = ldc_state(vio->lp);
739 err = ldc_bind(vio->lp, vio->name);
743 vio->name, vio->vdev->channel_id, err);
747 err = ldc_connect(vio->lp);
751 vio->name, vio->vdev->channel_id, err);
757 mod_timer(&vio->timer, expires);
760 spin_unlock_irqrestore(&vio->lock, flags);
766 struct vio_driver_state *vio = (struct vio_driver_state *) _arg;
768 vio_port_up(vio);
771 int vio_driver_init(struct vio_driver_state *vio, struct vio_dev *vdev,
798 spin_lock_init(&vio->lock);
800 vio->name = name;
802 vio->dev_class = dev_class;
803 vio->vdev = vdev;
805 vio->ver_table = ver_table;
806 vio->ver_table_entries = ver_table_size;
808 vio->ops = ops;
810 setup_timer(&vio->timer, vio_port_timer, (unsigned long) vio);