arch/sparc/kernel/viohs.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/viohs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/viohs.c- Extension
.c- Size
- 19025 bytes
- Lines
- 861
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/export.hlinux/string.hlinux/delay.hlinux/sched.hlinux/sched/clock.hlinux/slab.hasm/ldc.hasm/vio.h
Detected Declarations
function Copyrightfunction send_ctrlfunction init_tagfunction send_versionfunction start_handshakefunction flush_rx_dringfunction vio_link_state_changefunction handshake_failurefunction process_unknownfunction send_dregfunction send_rdxfunction send_attrfunction process_ver_infofunction process_ver_ackfunction process_ver_nackfunction process_verfunction process_attrfunction all_drings_registeredfunction process_dreg_infofunction process_dreg_ackfunction process_dreg_nackfunction process_dregfunction process_dunregfunction process_rdx_infofunction process_rdx_ackfunction process_rdx_nackfunction process_rdxfunction vio_control_pkt_enginefunction vio_conn_resetfunction vio_validate_sidfunction vio_send_sidfunction vio_ldc_allocfunction vio_ldc_freefunction vio_port_upfunction vio_port_timerfunction vio_driver_initexport vio_ldc_sendexport vio_link_state_changeexport vio_control_pkt_engineexport vio_conn_resetexport vio_validate_sidexport vio_send_sidexport vio_ldc_allocexport vio_ldc_freeexport vio_port_upexport vio_driver_init
Annotated Snippet
switch (vio->dev_class) {
case VDEV_NETWORK:
case VDEV_NETWORK_SWITCH:
vio->dr_state = (VIO_DR_STATE_TXREQ |
VIO_DR_STATE_RXREQ);
break;
case VDEV_DISK:
vio->dr_state = VIO_DR_STATE_TXREQ;
break;
case VDEV_DISK_SERVER:
vio->dr_state = VIO_DR_STATE_RXREQ;
break;
}
start_handshake(vio);
} else if (event == LDC_EVENT_RESET) {
vio->hs_state = VIO_HS_INVALID;
if (vio->dr_state & VIO_DR_STATE_RXREG)
flush_rx_dring(vio);
vio->dr_state = 0x00;
memset(&vio->ver, 0, sizeof(vio->ver));
ldc_disconnect(vio->lp);
}
}
EXPORT_SYMBOL(vio_link_state_change);
static int handshake_failure(struct vio_driver_state *vio)
{
struct vio_dring_state *dr;
/* XXX Put policy here... Perhaps start a timer to fire
* XXX in 100 ms, which will bring the link up and retry
* XXX the handshake.
*/
viodbg(HS, "HANDSHAKE FAILURE\n");
vio->dr_state &= ~(VIO_DR_STATE_TXREG |
VIO_DR_STATE_RXREG);
dr = &vio->drings[VIO_DRIVER_RX_RING];
memset(dr, 0, sizeof(*dr));
kfree(vio->desc_buf);
vio->desc_buf = NULL;
vio->desc_buf_len = 0;
vio->hs_state = VIO_HS_INVALID;
return -ECONNRESET;
}
static int process_unknown(struct vio_driver_state *vio, void *arg)
{
struct vio_msg_tag *pkt = arg;
viodbg(HS, "UNKNOWN CONTROL [%02x:%02x:%04x:%08x]\n",
pkt->type, pkt->stype, pkt->stype_env, pkt->sid);
printk(KERN_ERR "vio: ID[%lu] Resetting connection.\n",
vio->vdev->channel_id);
ldc_disconnect(vio->lp);
return -ECONNRESET;
}
static int send_dreg(struct vio_driver_state *vio)
{
struct vio_dring_state *dr = &vio->drings[VIO_DRIVER_TX_RING];
union {
struct vio_dring_register pkt;
char all[sizeof(struct vio_dring_register) +
(sizeof(struct ldc_trans_cookie) *
VIO_MAX_RING_COOKIES)];
} u;
size_t bytes = sizeof(struct vio_dring_register) +
(sizeof(struct ldc_trans_cookie) *
dr->ncookies);
int i;
if (WARN_ON(bytes > sizeof(u)))
return -EINVAL;
memset(&u, 0, bytes);
init_tag(&u.pkt.tag, VIO_TYPE_CTRL, VIO_SUBTYPE_INFO, VIO_DRING_REG);
u.pkt.dring_ident = 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/string.h`, `linux/delay.h`, `linux/sched.h`, `linux/sched/clock.h`, `linux/slab.h`, `asm/ldc.h`.
- Detected declarations: `function Copyright`, `function send_ctrl`, `function init_tag`, `function send_version`, `function start_handshake`, `function flush_rx_dring`, `function vio_link_state_change`, `function handshake_failure`, `function process_unknown`, `function send_dreg`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.