Module Name: src Committed By: palle Date: Wed Feb 5 20:46:27 UTC 2025
Modified Files: src/sys/arch/sparc64/dev: ldc.c ldcvar.h Log Message: sun4v ldc: improve the ldc_send_xxx functions so they can print an error message and return a proper error code To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/dev/ldc.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/ldcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc64/dev/ldc.c diff -u src/sys/arch/sparc64/dev/ldc.c:1.8 src/sys/arch/sparc64/dev/ldc.c:1.9 --- src/sys/arch/sparc64/dev/ldc.c:1.8 Wed Dec 20 05:33:58 2023 +++ src/sys/arch/sparc64/dev/ldc.c Wed Feb 5 20:46:26 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: ldc.c,v 1.8 2023/12/20 05:33:58 thorpej Exp $ */ +/* $NetBSD: ldc.c,v 1.9 2025/02/05 20:46:26 palle Exp $ */ /* $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -38,10 +38,10 @@ void ldc_rx_ctrl_rtr(struct ldc_conn *, void ldc_rx_ctrl_rts(struct ldc_conn *, struct ldc_pkt *); void ldc_rx_ctrl_rdx(struct ldc_conn *, struct ldc_pkt *); -void ldc_send_ack(struct ldc_conn *); -void ldc_send_rtr(struct ldc_conn *); -void ldc_send_rts(struct ldc_conn *); -void ldc_send_rdx(struct ldc_conn *); +int ldc_send_ack(struct ldc_conn *); +int ldc_send_rtr(struct ldc_conn *); +int ldc_send_rts(struct ldc_conn *); +int ldc_send_rdx(struct ldc_conn *); void ldc_rx_ctrl(struct ldc_conn *lc, struct ldc_pkt *lp) @@ -242,7 +242,7 @@ ldc_rx_data(struct ldc_conn *lc, struct lc->lc_rx_data(lc, (struct ldc_pkt *)lc->lc_msg); } -void +int ldc_send_vers(struct ldc_conn *lc) { struct ldc_pkt *lp; @@ -253,7 +253,7 @@ ldc_send_vers(struct ldc_conn *lc) err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); @@ -261,8 +261,8 @@ ldc_send_vers(struct ldc_conn *lc) lp->type = LDC_CTRL; lp->stype = LDC_INFO; lp->ctrl = LDC_VERS; - lp->major = 1; - lp->minor = 0; + lp->major = LDC_VERSION_MAJOR; + lp->minor = LDC_VERSION_MINOR; DPRINTF(("ldc_send_vers() major %d minor %d\n", lp->major, lp->minor)); tx_tail += sizeof(*lp); @@ -271,15 +271,16 @@ ldc_send_vers(struct ldc_conn *lc) if (err != H_EOK) { printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err); mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lc->lc_state = LDC_SND_VERS; DPRINTF(("ldc_send_vers() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(&lc->lc_txq->lq_mtx); + return 0; } -void +int ldc_send_ack(struct ldc_conn *lc) { struct ldc_pkt *lp; @@ -290,7 +291,8 @@ ldc_send_ack(struct ldc_conn *lc) err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); - return; + printf("ldc_send_ack() err %d tx_state %lu\n", err, tx_state); + return EIO; } lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); @@ -307,15 +309,16 @@ ldc_send_ack(struct ldc_conn *lc) if (err != H_EOK) { printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err); mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lc->lc_state = LDC_RCV_VERS; DPRINTF(("ldc_send_ack() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(&lc->lc_txq->lq_mtx); + return 0; } -void +int ldc_send_rts(struct ldc_conn *lc) { struct ldc_pkt *lp; @@ -326,7 +329,8 @@ ldc_send_rts(struct ldc_conn *lc) err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); - return; + printf("ldc_send_rts() err %d tx_state %lu\n", err, tx_state); + return EIO; } lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); @@ -343,15 +347,16 @@ ldc_send_rts(struct ldc_conn *lc) if (err != H_EOK) { printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err); mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lc->lc_state = LDC_SND_RTS; DPRINTF(("ldc_send_rts() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(&lc->lc_txq->lq_mtx); + return 0; } -void +int ldc_send_rtr(struct ldc_conn *lc) { struct ldc_pkt *lp; @@ -362,7 +367,8 @@ ldc_send_rtr(struct ldc_conn *lc) err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); - return; + printf("ldc_send_rtr() err %d state %lu\n", err, tx_state); + return EIO; } lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); @@ -379,15 +385,16 @@ ldc_send_rtr(struct ldc_conn *lc) if (err != H_EOK) { printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err); mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lc->lc_state = LDC_SND_RTR; DPRINTF(("ldc_send_rtr() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(&lc->lc_txq->lq_mtx); + return 0; } -void +int ldc_send_rdx(struct ldc_conn *lc) { struct ldc_pkt *lp; @@ -398,7 +405,8 @@ ldc_send_rdx(struct ldc_conn *lc) err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); - return; + printf("ldc_send_rdx() err %d state %lu\n", err, tx_state); + return EIO; } lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_txq->lq_va + tx_tail); @@ -415,12 +423,13 @@ ldc_send_rdx(struct ldc_conn *lc) if (err != H_EOK) { printf("%s: hv_ldc_tx_set_qtail: %d\n", __func__, err); mutex_exit(&lc->lc_txq->lq_mtx); - return; + return EIO; } lc->lc_state = LDC_SND_RDX; DPRINTF(("ldc_send_rdx() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(&lc->lc_txq->lq_mtx); + return 0; } int @@ -436,6 +445,7 @@ ldc_send_unreliable(struct ldc_conn *lc, err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); if (err != H_EOK || tx_state != LDC_CHANNEL_UP) { mutex_exit(&lc->lc_txq->lq_mtx); + printf("ldc_send_unrealiable() err %d state %lu\n", err, tx_state); return (EIO); } Index: src/sys/arch/sparc64/dev/ldcvar.h diff -u src/sys/arch/sparc64/dev/ldcvar.h:1.1 src/sys/arch/sparc64/dev/ldcvar.h:1.2 --- src/sys/arch/sparc64/dev/ldcvar.h:1.1 Fri Aug 19 19:02:07 2016 +++ src/sys/arch/sparc64/dev/ldcvar.h Wed Feb 5 20:46:26 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: ldcvar.h,v 1.1 2016/08/19 19:02:07 palle Exp $ */ +/* $NetBSD: ldcvar.h,v 1.2 2025/02/05 20:46:26 palle Exp $ */ /* $OpenBSD: ldcvar.h,v 1.6 2014/09/29 17:43:29 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -121,7 +121,7 @@ struct ldc_conn { void ldc_rx_ctrl(struct ldc_conn *, struct ldc_pkt *); void ldc_rx_data(struct ldc_conn *, struct ldc_pkt *); -void ldc_send_vers(struct ldc_conn *); +int ldc_send_vers(struct ldc_conn *); int ldc_send_unreliable(struct ldc_conn *, void *, size_t); void ldc_reset(struct ldc_conn *);