lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

  • 1 participants
  • 97208 discussions
Change in osmo-uecups[master]: daemon: log more details when netdev_add_defaultroute() fails
by fixeria 30 Jan '22

30 Jan '22
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-uecups/+/27021 ) Change subject: daemon: log more details when netdev_add_defaultroute() fails ...................................................................... daemon: log more details when netdev_add_defaultroute() fails Change-Id: I4ac09ec528e6e9169cca813995ba0db583b212a0 Related: SYS#5602 --- M daemon/tun_device.c 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-uecups refs/changes/21/27021/1 diff --git a/daemon/tun_device.c b/daemon/tun_device.c index b1bd7fc..7d1948f 100644 --- a/daemon/tun_device.c +++ b/daemon/tun_device.c @@ -290,13 +290,15 @@ if (tun->netns_name) { rc = netdev_add_defaultroute(tun->nl, tun->ifindex, AF_INET); if (rc < 0) - LOGTUN(tun, LOGL_ERROR, "Cannot add IPv4 default route\n"); + LOGTUN(tun, LOGL_ERROR, "Cannot add IPv4 default route " + "(rc=%d): %s\n", rc, nl_geterror(rc)); else LOGTUN(tun, LOGL_INFO, "Added IPv4 default route\n"); rc = netdev_add_defaultroute(tun->nl, tun->ifindex, AF_INET6); if (rc < 0) - LOGTUN(tun, LOGL_ERROR, "Cannot add IPv6 default route\n"); + LOGTUN(tun, LOGL_ERROR, "Cannot add IPv6 default route " + "(rc=%d): %s\n", rc, nl_geterror(rc)); else LOGTUN(tun, LOGL_INFO, "Added IPv6 default route\n"); } -- To view, visit https://gerrit.osmocom.org/c/osmo-uecups/+/27021 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-uecups Gerrit-Branch: master Gerrit-Change-Id: I4ac09ec528e6e9169cca813995ba0db583b212a0 Gerrit-Change-Number: 27021 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1d[master]: GPS-DO support for icE1usb hardware
by laforge 30 Jan '22

30 Jan '22
Attention is currently required from: roox, laforge, tnt. Hello Jenkins Builder, roox, tnt, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-e1d/+/27020 to look at the new patch set (#2). Change subject: GPS-DO support for icE1usb hardware ...................................................................... GPS-DO support for icE1usb hardware This adds support for monitoring the GPS-DO that is built-in to the icE1usb device. It assumes a very recent firmware with GPS-DO control moved to a separate USB interface, i.e. after osmo-e1-hardware.git Change-Id Icd6555a14896c38626fb147b78af44ff719f2254 is merged. Change-Id: If5e2a6b2dae0290ce3186009e68f618049ebf5ff --- M src/ice1usb_proto.h M src/usb.c M src/usb.h M src/vty.c 4 files changed, 316 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/20/27020/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27020 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: If5e2a6b2dae0290ce3186009e68f618049ebf5ff Gerrit-Change-Number: 27020 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: roox <mardnh(a)gmx.de> Gerrit-Reviewer: tnt <tnt(a)246tNt.com> Gerrit-Attention: roox <mardnh(a)gmx.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: tnt <tnt(a)246tNt.com> Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-e1d[master]: GPS-DO support for icE1usb hardware
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27020 ) Change subject: GPS-DO support for icE1usb hardware ...................................................................... GPS-DO support for icE1usb hardware This adds support for monitoring the GPS-DO that is built-in to the icE1usb device. It assumes a very recent firmware with GPS-DO control moved to a separate USB interface, i.e. after osmo-e1-hardware.git Change-Id Icd6555a14896c38626fb147b78af44ff719f2254 is merged. Change-Id: If5e2a6b2dae0290ce3186009e68f618049ebf5ff --- M src/ice1usb_proto.h M src/usb.c M src/usb.h M src/vty.c 4 files changed, 316 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/20/27020/1 diff --git a/src/ice1usb_proto.h b/src/ice1usb_proto.h index d0d7304..3170d55 100644 --- a/src/ice1usb_proto.h +++ b/src/ice1usb_proto.h @@ -23,8 +23,54 @@ ICE1USB_DEV_CAP_GPSDO, }; +/*********************************************************************** + * Control Endpoint / GPS-DO Interface Requests + ***********************************************************************/ -/* Interface Requests */ +#define ICE1USB_INTF_GET_GPSDO_STATUS 0x10 +#define ICE1USB_INTF_GET_GPSDO_MODE 0x12 /*!< uint8_t */ +#define ICE1USB_INTF_SET_GPSDO_MODE 0x13 /*!< wValue = mode */ +#define ICE1USB_INTF_GET_GPSDO_TUNE 0x14 /*!< data = struct e1usb_gpsdo_tune */ +#define ICE1USB_INTF_SET_GPSDO_TUNE 0x15 /*!< data = struct e1usb_gpsdo_tune */ + +enum ice1usb_gpsdo_mode { + ICE1USB_GPSDO_MODE_DISABLED = 0, + ICE1USB_GPSDO_MODE_AUTO = 1, +}; + +enum ice1usb_gpsdo_antenna_state { + ICE1USB_GPSDO_ANT_UNKNOWN = 0, + ICE1USB_GPSDO_ANT_OK = 1, + ICE1USB_GPSDO_ANT_OPEN = 2, + ICE1USB_GPSDO_ANT_SHORT = 3, +}; + +enum ice1usb_gpsdo_state { + ICE1USB_GPSDO_STATE_DISABLED = 0, + ICE1USB_GPSDO_STATE_CALIBRATE = 1, + ICE1USB_GPSDO_STATE_HOLD_OVER = 2, + ICE1USB_GPSDO_STATE_TUNE_COARSE = 3, + ICE1USB_GPSDO_STATE_TUNE_FINE = 4, +}; + +struct e1usb_gpsdo_tune { + uint16_t coarse; + uint16_t fine; +} __attribute__((packed)); + +struct e1usb_gpsdo_status { + uint8_t state; + uint8_t antenna_state; /*!< Antenna state */ + uint8_t valid_fix; /*!< Valid GPS Fix (0/1) */ + uint8_t mode; /*!< Current configured operating mode */ + struct e1usb_gpsdo_tune tune; /*!< Current VCXO tuning values */ + uint32_t freq_est; /*!< Latest frequency estimate measurement */ +} __attribute__((packed)); + + +/*********************************************************************** + * Control Endpoint / E1 Interface Requests + ***********************************************************************/ /*! returns a bit-mask of optional device capabilities (see enum e1usb_intf_capability) */ #define ICE1USB_INTF_GET_CAPABILITIES 0x01 @@ -32,6 +78,7 @@ #define ICE1USB_INTF_GET_TX_CFG 0x03 /*!< struct ice1usb_tx_config */ #define ICE1USB_INTF_SET_RX_CFG 0x04 /*!< struct ice1usb_rx_config */ #define ICE1USB_INTF_GET_RX_CFG 0x05 /*!< struct ice1usb_rx_config */ +#define ICE1USB_INTF_GET_ERRORS 0x06 /*!< struct ice1usb_irq_err */ //enum e1usb_intf_capability { }; diff --git a/src/usb.c b/src/usb.c index 1e853d3..ac72bdd 100644 --- a/src/usb.c +++ b/src/usb.c @@ -30,6 +30,7 @@ #include <osmocom/core/isdnhdlc.h> #include <osmocom/core/utils.h> +#include <osmocom/core/bit32gen.h> #include <osmocom/usb/libusb.h> #include <libusb.h> @@ -84,6 +85,15 @@ struct e1_usb_intf_data { libusb_device_handle *devh; + + struct { + uint8_t if_num; + struct osmo_timer_list poll_timer; + struct e1usb_gpsdo_status last_status; + } gpsdo; + + /* list of in-progress CTRL operations */ + struct llist_head ctrl_inprogress; }; @@ -415,7 +425,7 @@ } // --------------------------------------------------------------------------- -// Control transfers +// Control transfers (USB interface == E1 line level) // --------------------------------------------------------------------------- struct e1_usb_ctrl_xfer { @@ -445,6 +455,10 @@ libusb_free_transfer(xfr); } +// --------------------------------------------------------------------------- +// Control transfers (USB device == E1 interface level) +// --------------------------------------------------------------------------- + /* generic helper for async transmission of control endpoint requests */ static int _e1_usb_line_send_ctrl(struct e1_line *line, uint8_t bmReqType, uint8_t bReq, uint16_t wValue, @@ -518,6 +532,224 @@ sizeof(rx_cfg)); } +struct e1_usb_ctrl_xfer_intf { + struct e1_intf *intf; + struct llist_head list; + /* 8 bytes control setup packet, remainder for data */ + uint8_t buffer[8 + sizeof(struct e1usb_gpsdo_status)]; +}; + +static void _e1_usb_intf_gpsdo_status_cb(struct e1_intf *intf, const uint8_t *data, size_t len); + +static void +ctrl_xfer_intf_compl_cb(struct libusb_transfer *xfr) +{ + struct e1_usb_ctrl_xfer_intf *ucx = xfr->user_data; + struct libusb_control_setup *setup; + + switch (xfr->status) { + case LIBUSB_TRANSFER_COMPLETED: + setup = (struct libusb_control_setup *) ucx->buffer; + LOGPIF(ucx->intf, DE1D, LOGL_DEBUG, "CTRL transfer completed successfully: %s\n", + osmo_hexdump(ucx->buffer, 8+xfr->actual_length)); + switch (setup->bRequest) { + case ICE1USB_INTF_GET_GPSDO_STATUS: + _e1_usb_intf_gpsdo_status_cb(ucx->intf, ucx->buffer+8, xfr->actual_length); + break; + default: + break; + } + break; + default: + LOGPIF(ucx->intf, DE1D, LOGL_ERROR, "CTRL transfer completed unsuccessfully %d\n", + xfr->status); + break; + } + llist_del(&ucx->list); + talloc_free(ucx); + libusb_free_transfer(xfr); +} + + +/* generic helper for async transmission of control endpoint requests */ +static int +_e1_usb_intf_send_ctrl(struct e1_intf *intf, uint8_t bmReqType, uint8_t bReq, uint16_t wValue, + const uint8_t *data, size_t data_len) +{ + struct e1_usb_ctrl_xfer_intf *ucx = talloc_zero(intf, struct e1_usb_ctrl_xfer_intf); + struct e1_usb_intf_data *id = (struct e1_usb_intf_data *) intf->drv_data; + struct libusb_transfer *xfr; + int rc; + + if (!ucx) + return -ENOMEM; + + OSMO_ASSERT(sizeof(ucx->buffer) >= 8+data_len); + ucx->intf = intf; + libusb_fill_control_setup(ucx->buffer, bmReqType, bReq, wValue, id->gpsdo.if_num, data_len); + if (data && data_len) + memcpy(ucx->buffer+8, data, data_len); + + xfr = libusb_alloc_transfer(0); + if (!xfr) { + rc = -ENOMEM; + goto free_ucx; + } + + libusb_fill_control_transfer(xfr, id->devh, ucx->buffer, ctrl_xfer_intf_compl_cb, ucx, 3000); + rc = libusb_submit_transfer(xfr); + if (rc != 0) + goto free_xfr; + + llist_add_tail(&ucx->list, &id->ctrl_inprogress); + + return 0; + +free_xfr: + libusb_free_transfer(xfr); +free_ucx: + talloc_free(ucx); + + return rc; +} + +int +e1_usb_ctrl_set_gpsdo_mode(struct e1_intf *intf, enum ice1usb_gpsdo_mode gpsdo_mode) +{ + const uint16_t bmReqType = LIBUSB_RECIPIENT_INTERFACE | LIBUSB_REQUEST_TYPE_VENDOR | + LIBUSB_ENDPOINT_OUT; + return _e1_usb_intf_send_ctrl(intf, bmReqType, ICE1USB_INTF_SET_GPSDO_MODE, 0, + (uint8_t *)&gpsdo_mode, sizeof(gpsdo_mode)); +} + +int +e1_usb_ctrl_set_gpsdo_tune(struct e1_intf *intf, const struct e1usb_gpsdo_tune *gpsdo_tune) +{ + const uint16_t bmReqType = LIBUSB_RECIPIENT_INTERFACE | LIBUSB_REQUEST_TYPE_VENDOR | + LIBUSB_ENDPOINT_OUT; + return _e1_usb_intf_send_ctrl(intf, bmReqType, ICE1USB_INTF_SET_GPSDO_TUNE, 0, + (uint8_t *)gpsdo_tune, sizeof(gpsdo_tune)); +} + +int +e1_usb_ctrl_get_gpsdo_status(struct e1_intf *intf) +{ + const uint16_t bmReqType = LIBUSB_RECIPIENT_INTERFACE | LIBUSB_REQUEST_TYPE_VENDOR | + LIBUSB_ENDPOINT_IN; + return _e1_usb_intf_send_ctrl(intf, bmReqType, ICE1USB_INTF_GET_GPSDO_STATUS, 0, + NULL, sizeof(struct e1usb_gpsdo_status)); +} + +// --------------------------------------------------------------------------- +// GPS-DO +// --------------------------------------------------------------------------- + +static const struct value_string ice1usb_gpsdo_mode_str[] = { + { ICE1USB_GPSDO_MODE_DISABLED, "DISABLED" }, + { ICE1USB_GPSDO_MODE_AUTO, "AUTO" }, + { 0, NULL } +}; + +static const struct value_string ice1usb_gpsdo_antenna_state_str[] = { + { ICE1USB_GPSDO_ANT_UNKNOWN, "UNKNOWN" }, + { ICE1USB_GPSDO_ANT_OK, "OK" }, + { ICE1USB_GPSDO_ANT_OPEN, "OPEN" }, + { ICE1USB_GPSDO_ANT_SHORT, "SHORT" }, + { 0, NULL } +}; + +static const struct value_string ice1usb_gpsdo_state_str[] = { + { ICE1USB_GPSDO_STATE_DISABLED, "DISABLED" }, + { ICE1USB_GPSDO_STATE_CALIBRATE, "CALIBRATE" }, + { ICE1USB_GPSDO_STATE_HOLD_OVER, "HOLD_OVER" }, + { ICE1USB_GPSDO_STATE_TUNE_COARSE, "TUNE_COARSE" }, + { ICE1USB_GPSDO_STATE_TUNE_FINE, "TUNE_FINE" }, + { 0, NULL } +}; + +int +e1_usb_intf_gpsdo_state_string(char *buf, size_t len, const struct e1_intf *intf) +{ + struct e1_usb_intf_data *id = intf->drv_data; + struct e1usb_gpsdo_status *last_st = &id->gpsdo.last_status; + + OSMO_ASSERT(intf->drv == E1_DRIVER_USB); + + return snprintf(buf, len, "mode=%s, fix=%s, state=%s antenna=%s, tune=%u/%u, freq_est=%u", + get_value_string(ice1usb_gpsdo_mode_str, last_st->mode), + last_st->valid_fix ? "TRUE" : "FALSE", + get_value_string(ice1usb_gpsdo_state_str, last_st->state), + get_value_string(ice1usb_gpsdo_antenna_state_str, last_st->antenna_state), + libusb_le16_to_cpu(last_st->tune.coarse), libusb_le16_to_cpu(last_st->tune.fine), + osmo_load32le(&last_st->freq_est)); +} + +static void +_e1_usb_intf_gpsdo_status_cb(struct e1_intf *intf, const uint8_t *data, size_t len) +{ + struct e1_usb_intf_data *id = intf->drv_data; + struct e1usb_gpsdo_status *last_st = &id->gpsdo.last_status; + const struct e1usb_gpsdo_status *st; + + if (len < sizeof(*st)) { + LOGPIF(intf, DE1D, LOGL_ERROR, "GPSDO status %zu < %zu!\n", len, sizeof(*st)); + return; + } + st = (const struct e1usb_gpsdo_status *) data; + + if (st->state != last_st->state) { + LOGPIF(intf, DE1D, LOGL_NOTICE, "GPSDO state change: %s -> %s\n", + get_value_string(ice1usb_gpsdo_state_str, last_st->state), + get_value_string(ice1usb_gpsdo_state_str, st->state)); + } + + if (st->antenna_state != last_st->antenna_state) { + int level = LOGL_NOTICE; + switch (st->antenna_state) { + case ICE1USB_GPSDO_ANT_OPEN: + case ICE1USB_GPSDO_ANT_SHORT: + level = LOGL_ERROR; + break; + default: + level = LOGL_NOTICE; + } + LOGPIF(intf, DE1D, level, "GPS antenna status change: %s -> %s\n", + get_value_string(ice1usb_gpsdo_antenna_state_str, last_st->antenna_state), + get_value_string(ice1usb_gpsdo_antenna_state_str, st->antenna_state)); + } + + if (st->valid_fix != last_st->valid_fix) { + if (st->valid_fix) + LOGPIF(intf, DE1D, LOGL_NOTICE, "GPS Fix achieved\n"); + else + LOGPIF(intf, DE1D, LOGL_ERROR, "GPS Fix LOST\n"); + } + + /* update our state */ + memcpy(last_st, st, sizeof(*last_st)); +} + +static void +_e1_usb_gpsdo_poll_cb(void *data) +{ + struct e1_intf *intf = (struct e1_intf *) data; + struct e1_usb_intf_data *id = intf->drv_data; + + /* issue a control endpoint request, further processing is when it completes */ + e1_usb_ctrl_get_gpsdo_status(intf); + + osmo_timer_schedule(&id->gpsdo.poll_timer, 1, 0); +} + +static void +_e1_usb_gpsdo_init(struct e1_intf *intf) +{ + struct e1_usb_intf_data *id = intf->drv_data; + + osmo_timer_setup(&id->gpsdo.poll_timer, &_e1_usb_gpsdo_poll_cb, intf); + osmo_timer_schedule(&id->gpsdo.poll_timer, 1, 0); +} + // --------------------------------------------------------------------------- // Init / Probing // --------------------------------------------------------------------------- @@ -583,6 +815,8 @@ osmo_talloc_replace_string(intf, &intf->usb.serial_str, serial_str); } + INIT_LLIST_HEAD(&intf_data->ctrl_inprogress); + ret = libusb_get_active_config_descriptor(dev, &cd); if (ret) { LOGP(DE1D, LOGL_ERROR, "Failed to talk to usb device\n"); @@ -686,6 +920,20 @@ line_nr++; } + /* find the GPS-DO interface (if any) */ + for (i = 0; i < cd->bNumInterfaces; i++) { + if (cd->interface[i].num_altsetting != 1) + continue; + + id = &cd->interface[i].altsetting[0]; + if ((id->bInterfaceClass == 0xff) && (id->bInterfaceSubClass == 0xe1) && + (id->bInterfaceProtocol == 0xd0)) { + intf_data->gpsdo.if_num = id->bInterfaceNumber; + _e1_usb_gpsdo_init(intf); + break; + } + } + return 0; } diff --git a/src/usb.h b/src/usb.h index 7142686..41b4b2e 100644 --- a/src/usb.h +++ b/src/usb.h @@ -12,4 +12,10 @@ int e1_usb_ctrl_set_rx_cfg(struct e1_line *line, enum ice1usb_rx_mode mode); +int e1_usb_ctrl_set_gpsdo_mode(struct e1_intf *intf, enum ice1usb_gpsdo_mode gpsdo_mode); +int e1_usb_ctrl_set_gpsdo_tune(struct e1_intf *intf, const struct e1usb_gpsdo_tune *gpsdo_tune); +int e1_usb_ctrl_get_gpsdo_status(struct e1_intf *intf); + +int e1_usb_intf_gpsdo_state_string(char *buf, size_t len, const struct e1_intf *intf); + int e1_usb_probe(struct e1_daemon *e1d); diff --git a/src/vty.c b/src/vty.c index 7d4292c..0407462 100644 --- a/src/vty.c +++ b/src/vty.c @@ -38,6 +38,7 @@ #include <osmocom/e1d/proto.h> #include "e1d.h" +#include "usb.h" struct e1_daemon *vty_e1d; @@ -75,8 +76,20 @@ static void vty_dump_intf(struct vty *vty, const struct e1_intf *intf) { + char buf[128]; + vty_out(vty, "Interface #%u (%s), Driver: %s%s", intf->id, intf_serno(intf), get_value_string(e1_driver_names, intf->drv), VTY_NEWLINE); + + /* TODO: put this behind some call-back */ + switch (intf->drv) { + case E1_DRIVER_USB: + e1_usb_intf_gpsdo_state_string(buf, sizeof(buf), intf); + vty_out(vty, " GPS-DO: %s%s", buf, VTY_NEWLINE); + break; + default: + break; + } } DEFUN(show_intf, show_intf_cmd, "show interface [<0-255>]", -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27020 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: If5e2a6b2dae0290ce3186009e68f618049ebf5ff Gerrit-Change-Number: 27020 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1d[master]: make rate_counters work
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27018 ) Change subject: make rate_counters work ...................................................................... make rate_counters work if we don't call rate_ctr_init(), the rate counter internal timer will not tick,a nd we will never get the per-s/per-m/per-h averages. Change-Id: Ib5b66c72079330ac161756bcf562d27536d7ce44 --- M src/osmo-e1d.c 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/18/27018/1 diff --git a/src/osmo-e1d.c b/src/osmo-e1d.c index 3ac9642..91bf78d 100644 --- a/src/osmo-e1d.c +++ b/src/osmo-e1d.c @@ -175,6 +175,7 @@ vty_init(&vty_info); logging_vty_add_cmds(); e1d_vty_init(e1d); + rate_ctr_init(e1d); handle_options(argc, argv); -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27018 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: Ib5b66c72079330ac161756bcf562d27536d7ce44 Gerrit-Change-Number: 27018 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1d[master]: update copyright statement
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27019 ) Change subject: update copyright statement ...................................................................... update copyright statement Change-Id: I1b4817207369e572a2b070443475289cc527c317 --- M src/osmo-e1d.c 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/19/27019/1 diff --git a/src/osmo-e1d.c b/src/osmo-e1d.c index 91bf78d..f86a92a 100644 --- a/src/osmo-e1d.c +++ b/src/osmo-e1d.c @@ -1,7 +1,8 @@ /* * osmo-e1d.c * - * (C) 2019 by Sylvain Munaut <tnt(a)246tNt.com> + * (C) 2019-2022 by Sylvain Munaut <tnt(a)246tNt.com> + * (C) 2019-2022 by Harald Welte <laforge(a)osmocom.org> * * All Rights Reserved * @@ -83,7 +84,7 @@ .name = "osmo-e1d", .version = PACKAGE_VERSION, .copyright = - "(C) 2019 by Sylvain Munaut <tnt(a)246tNt.com>\r\n", + "(C) 2019-2022 by Sylvain Munaut, Harald Welte and contributors\r\n", "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\r\n" "This is free software: you are free to change and redistribute it.\r\n" "There is NO WARRANTY, to the extent permitted by law.\r\n", -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27019 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I1b4817207369e572a2b070443475289cc527c317 Gerrit-Change-Number: 27019 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1-hardware[master]: icE1usb: Move GPS-DO USB control to separate USB interface
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27017 ) Change subject: icE1usb: Move GPS-DO USB control to separate USB interface ...................................................................... icE1usb: Move GPS-DO USB control to separate USB interface doing so significantly simplifies the development of a Linux kernel driver, as the GPS-DO only exists once (not twice, like the per-E1-line interface), and Linux kernel USB drivers typically are for an interface. There is an option to write a usb_device_driver, but doing so will exclude the per-interface drivers from still being probed in their usual fashion. While we introduce this new USB Interface for the GPS-DO, we also move the related control endpoint requests from the device level to the interface level. Finally, some naming inconsistency between "enum ice1usb_gpsod_antenna_state" vs. the member name antenna_status is resolved. Change-Id: Icd6555a14896c38626fb147b78af44ff719f2254 --- M firmware/ice40-riscv/icE1usb/Makefile M firmware/ice40-riscv/icE1usb/fw_app.c M firmware/ice40-riscv/icE1usb/gpsdo.c M firmware/ice40-riscv/icE1usb/ice1usb_proto.h M firmware/ice40-riscv/icE1usb/usb_desc_app.c M firmware/ice40-riscv/icE1usb/usb_desc_ids.h M firmware/ice40-riscv/icE1usb/usb_dev.c A firmware/ice40-riscv/icE1usb/usb_gpsdo.c A firmware/ice40-riscv/icE1usb/usb_gpsdo.h M firmware/ice40-riscv/icE1usb/usb_str_app.txt 10 files changed, 170 insertions(+), 80 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/17/27017/1 diff --git a/firmware/ice40-riscv/icE1usb/Makefile b/firmware/ice40-riscv/icE1usb/Makefile index 25c65d1..ed765f6 100644 --- a/firmware/ice40-riscv/icE1usb/Makefile +++ b/firmware/ice40-riscv/icE1usb/Makefile @@ -56,6 +56,7 @@ usb_dev.h \ usb_e1.h \ usb_gps.h \ + usb_gpsdo.h \ usb_str_app.gen.h \ $(NULL) @@ -69,6 +70,7 @@ usb_dev.c \ usb_e1.c \ usb_gps.c \ + usb_gpsdo.c \ $(NULL) diff --git a/firmware/ice40-riscv/icE1usb/fw_app.c b/firmware/ice40-riscv/icE1usb/fw_app.c index c1fe295..540eda2 100644 --- a/firmware/ice40-riscv/icE1usb/fw_app.c +++ b/firmware/ice40-riscv/icE1usb/fw_app.c @@ -23,6 +23,7 @@ #include "usb_dev.h" #include "usb_e1.h" #include "usb_gps.h" +#include "usb_gpsdo.h" #include "utils.h" @@ -109,6 +110,7 @@ usb_dfu_rt_init(); usb_e1_init(); usb_gps_init(); + usb_gpsdo_init(); /* Start */ led_state(true); diff --git a/firmware/ice40-riscv/icE1usb/gpsdo.c b/firmware/ice40-riscv/icE1usb/gpsdo.c index ae131d4..8e32627 100644 --- a/firmware/ice40-riscv/icE1usb/gpsdo.c +++ b/firmware/ice40-riscv/icE1usb/gpsdo.c @@ -96,7 +96,7 @@ }; status->state = state_map[g_gpsdo.state]; - status->antenna_status = ant_map[gps_antenna_status()]; + status->antenna_state = ant_map[gps_antenna_status()]; status->valid_fix = gps_has_valid_fix(); status->mode = (g_gpsdo.state == STATE_DISABLED) ? ICE1USB_GPSDO_MODE_DISABLED : ICE1USB_GPSDO_MODE_AUTO; status->tune.coarse = g_gpsdo.tune.coarse; diff --git a/firmware/ice40-riscv/icE1usb/ice1usb_proto.h b/firmware/ice40-riscv/icE1usb/ice1usb_proto.h index a249537..3170d55 100644 --- a/firmware/ice40-riscv/icE1usb/ice1usb_proto.h +++ b/firmware/ice40-riscv/icE1usb/ice1usb_proto.h @@ -17,17 +17,22 @@ /*! returns a bit-mask of optional device capabilities (see enum e1usb_dev_capability) */ #define ICE1USB_DEV_GET_CAPABILITIES 0x01 #define ICE1USB_DEV_GET_FW_BUILD 0x02 -#define ICE1USB_DEV_GET_GPSDO_STATUS 0x10 -#define ICE1USB_DEV_GET_GPSDO_MODE 0x12 /*!< uint8_t */ -#define ICE1USB_DEV_SET_GPSDO_MODE 0x13 /*!< wValue = mode */ -#define ICE1USB_DEV_GET_GPSDO_TUNE 0x14 /*!< data = struct e1usb_gpsdo_tune */ -#define ICE1USB_DEV_SET_GPSDO_TUNE 0x15 /*!< data = struct e1usb_gpsdo_tune */ enum e1usb_dev_capability { /*! Does this board have a GPS-DO */ ICE1USB_DEV_CAP_GPSDO, }; +/*********************************************************************** + * Control Endpoint / GPS-DO Interface Requests + ***********************************************************************/ + +#define ICE1USB_INTF_GET_GPSDO_STATUS 0x10 +#define ICE1USB_INTF_GET_GPSDO_MODE 0x12 /*!< uint8_t */ +#define ICE1USB_INTF_SET_GPSDO_MODE 0x13 /*!< wValue = mode */ +#define ICE1USB_INTF_GET_GPSDO_TUNE 0x14 /*!< data = struct e1usb_gpsdo_tune */ +#define ICE1USB_INTF_SET_GPSDO_TUNE 0x15 /*!< data = struct e1usb_gpsdo_tune */ + enum ice1usb_gpsdo_mode { ICE1USB_GPSDO_MODE_DISABLED = 0, ICE1USB_GPSDO_MODE_AUTO = 1, @@ -55,7 +60,7 @@ struct e1usb_gpsdo_status { uint8_t state; - uint8_t antenna_status; /*!< Antenna status */ + uint8_t antenna_state; /*!< Antenna state */ uint8_t valid_fix; /*!< Valid GPS Fix (0/1) */ uint8_t mode; /*!< Current configured operating mode */ struct e1usb_gpsdo_tune tune; /*!< Current VCXO tuning values */ @@ -63,7 +68,9 @@ } __attribute__((packed)); -/* Interface Requests */ +/*********************************************************************** + * Control Endpoint / E1 Interface Requests + ***********************************************************************/ /*! returns a bit-mask of optional device capabilities (see enum e1usb_intf_capability) */ #define ICE1USB_INTF_GET_CAPABILITIES 0x01 diff --git a/firmware/ice40-riscv/icE1usb/usb_desc_app.c b/firmware/ice40-riscv/icE1usb/usb_desc_app.c index e0edf80..653d204 100644 --- a/firmware/ice40-riscv/icE1usb/usb_desc_app.c +++ b/firmware/ice40-riscv/icE1usb/usb_desc_app.c @@ -53,6 +53,11 @@ struct usb_ep_desc ep_data_in; } __attribute__ ((packed)) cdc; + /* GPS-DO (control EP only) */ + struct { + struct usb_intf_desc intf; + } __attribute__ ((packed)) gpsdo; + /* DFU Runtime */ struct { struct usb_intf_desc intf; @@ -275,6 +280,19 @@ .bInterval = 0x00, }, }, + .gpsdo = { + .intf = { + .bLength = sizeof(struct usb_intf_desc), + .bDescriptorType = USB_DT_INTF, + .bInterfaceNumber = USB_INTF_GPSDO, + .bAlternateSetting = 0, + .bNumEndpoints = 0, + .bInterfaceClass = 0xff, + .bInterfaceSubClass = 0xe1, + .bInterfaceProtocol = 0xd0, + .iInterface = 12, + } + }, .dfu = { .intf = { .bLength = sizeof(struct usb_intf_desc), diff --git a/firmware/ice40-riscv/icE1usb/usb_desc_ids.h b/firmware/ice40-riscv/icE1usb/usb_desc_ids.h index 3fbc417..137f853 100644 --- a/firmware/ice40-riscv/icE1usb/usb_desc_ids.h +++ b/firmware/ice40-riscv/icE1usb/usb_desc_ids.h @@ -11,7 +11,8 @@ #define USB_INTF_DFU 2 #define USB_INTF_GPS_CDC_CTL 3 #define USB_INTF_GPS_CDC_DATA 4 -#define USB_INTF_NUM 5 +#define USB_INTF_GPSDO 5 +#define USB_INTF_NUM 6 #define USB_EP_E1_IN(p) (0x82 + (3 * (p))) #define USB_EP_E1_OUT(p) (0x01 + (3 * (p))) diff --git a/firmware/ice40-riscv/icE1usb/usb_dev.c b/firmware/ice40-riscv/icE1usb/usb_dev.c index 2997a33..e19d9a0 100644 --- a/firmware/ice40-riscv/icE1usb/usb_dev.c +++ b/firmware/ice40-riscv/icE1usb/usb_dev.c @@ -12,7 +12,6 @@ #include <no2usb/usb_proto.h> #include "console.h" -#include "gpsdo.h" #include "misc.h" #include "ice1usb_proto.h" @@ -21,61 +20,6 @@ const char *fw_build_str = BUILD_INFO; -static void -_get_gpsdo_status(struct usb_ctrl_req *req, struct usb_xfer *xfer) -{ - struct e1usb_gpsdo_status status; - - gpsdo_get_status(&status); - - memcpy(xfer->data, &status, sizeof(struct e1usb_gpsdo_status)); - xfer->len = sizeof(struct e1usb_gpsdo_status); -} - -static void -_get_gpsdo_mode(struct usb_ctrl_req *req, struct usb_xfer *xfer) -{ - xfer->data[0] = gpsdo_enabled() ? ICE1USB_GPSDO_MODE_DISABLED : ICE1USB_GPSDO_MODE_AUTO; - xfer->len = 1; -} - -static void -_set_gpsdo_mode(struct usb_ctrl_req *req, struct usb_xfer *xfer) -{ - gpsdo_enable(req->wValue != ICE1USB_GPSDO_MODE_DISABLED); -} - -static void -_get_gpsdo_tune(struct usb_ctrl_req *req, struct usb_xfer *xfer) -{ - uint16_t coarse, fine; - struct e1usb_gpsdo_tune tune; - - gpsdo_get_tune(&coarse, &fine); - tune.coarse = coarse; - tune.fine = fine; - - memcpy(xfer->data, &tune, sizeof(struct e1usb_gpsdo_tune)); - xfer->len = sizeof(struct e1usb_gpsdo_tune); -} - -static bool -_set_gpsdo_tune_done(struct usb_xfer *xfer) -{ - const struct e1usb_gpsdo_tune *tune = (const void *) xfer->data; - gpsdo_set_tune(tune->coarse, tune->fine); - return true; -} - -static void -_set_gpsdo_tune(struct usb_ctrl_req *req, struct usb_xfer *xfer) -{ - xfer->cb_done = _set_gpsdo_tune_done; - xfer->cb_ctx = req; - xfer->len = sizeof(struct e1usb_gpsdo_tune); -} - - static enum usb_fnd_resp _usb_dev_ctrl_req(struct usb_ctrl_req *req, struct usb_xfer *xfer) { @@ -93,21 +37,6 @@ xfer->data = (void*) fw_build_str; xfer->len = strlen(fw_build_str); break; - case ICE1USB_DEV_GET_GPSDO_STATUS: - _get_gpsdo_status(req, xfer); - break; - case ICE1USB_DEV_GET_GPSDO_MODE: - _get_gpsdo_mode(req, xfer); - break; - case ICE1USB_DEV_SET_GPSDO_MODE: - _set_gpsdo_mode(req, xfer); - break; - case ICE1USB_DEV_GET_GPSDO_TUNE: - _get_gpsdo_tune(req, xfer); - break; - case ICE1USB_DEV_SET_GPSDO_TUNE: - _set_gpsdo_tune(req, xfer); - break; default: return USB_FND_ERROR; } diff --git a/firmware/ice40-riscv/icE1usb/usb_gpsdo.c b/firmware/ice40-riscv/icE1usb/usb_gpsdo.c new file mode 100644 index 0000000..4dd8913 --- /dev/null +++ b/firmware/ice40-riscv/icE1usb/usb_gpsdo.c @@ -0,0 +1,120 @@ +/* + * usb_gpsdo.c + * + * Copyright (C) 2019-2022 Sylvain Munaut <tnt(a)246tNt.com> + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#include <no2usb/usb.h> +#include <no2usb/usb_hw.h> +#include <no2usb/usb_priv.h> + +#include <no2usb/usb_proto.h> + +#include "usb_desc_ids.h" +#include "gpsdo.h" + +#include "ice1usb_proto.h" + +static void +_get_gpsdo_status(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + struct e1usb_gpsdo_status status; + + gpsdo_get_status(&status); + + memcpy(xfer->data, &status, sizeof(struct e1usb_gpsdo_status)); + xfer->len = sizeof(struct e1usb_gpsdo_status); +} + +static void +_get_gpsdo_mode(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + xfer->data[0] = gpsdo_enabled() ? ICE1USB_GPSDO_MODE_DISABLED : ICE1USB_GPSDO_MODE_AUTO; + xfer->len = 1; +} + +static void +_set_gpsdo_mode(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + gpsdo_enable(req->wValue != ICE1USB_GPSDO_MODE_DISABLED); +} + +static void +_get_gpsdo_tune(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + uint16_t coarse, fine; + struct e1usb_gpsdo_tune tune; + + gpsdo_get_tune(&coarse, &fine); + tune.coarse = coarse; + tune.fine = fine; + + memcpy(xfer->data, &tune, sizeof(struct e1usb_gpsdo_tune)); + xfer->len = sizeof(struct e1usb_gpsdo_tune); +} + +static bool +_set_gpsdo_tune_done(struct usb_xfer *xfer) +{ + const struct e1usb_gpsdo_tune *tune = (const void *) xfer->data; + gpsdo_set_tune(tune->coarse, tune->fine); + return true; +} + +static void +_set_gpsdo_tune(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + xfer->cb_done = _set_gpsdo_tune_done; + xfer->cb_ctx = req; + xfer->len = sizeof(struct e1usb_gpsdo_tune); +} + + +static enum usb_fnd_resp +_gpsdo_ctrl_req(struct usb_ctrl_req *req, struct usb_xfer *xfer) +{ + /* Check it's for an interface */ + if (USB_REQ_TYPE_RCPT(req) != (USB_REQ_TYPE_VENDOR | USB_REQ_RCPT_INTF)) + return USB_FND_CONTINUE; + + /* Check it's for the GPS-DO interface */ + if (req->wIndex != USB_INTF_GPSDO) + return USB_FND_CONTINUE; + + switch (req->bRequest) { + case ICE1USB_INTF_GET_GPSDO_STATUS: + _get_gpsdo_status(req, xfer); + break; + case ICE1USB_INTF_GET_GPSDO_MODE: + _get_gpsdo_mode(req, xfer); + break; + case ICE1USB_INTF_SET_GPSDO_MODE: + _set_gpsdo_mode(req, xfer); + break; + case ICE1USB_INTF_GET_GPSDO_TUNE: + _get_gpsdo_tune(req, xfer); + break; + case ICE1USB_INTF_SET_GPSDO_TUNE: + _set_gpsdo_tune(req, xfer); + break; + default: + return USB_FND_ERROR; + } + + return USB_FND_SUCCESS; +} + +static struct usb_fn_drv _gpsdo_drv = { + .ctrl_req = _gpsdo_ctrl_req, +}; + +void +usb_gpsdo_init(void) +{ + usb_register_function_driver(&_gpsdo_drv); +} diff --git a/firmware/ice40-riscv/icE1usb/usb_gpsdo.h b/firmware/ice40-riscv/icE1usb/usb_gpsdo.h new file mode 100644 index 0000000..4cf4203 --- /dev/null +++ b/firmware/ice40-riscv/icE1usb/usb_gpsdo.h @@ -0,0 +1,10 @@ +/* + * usb_gpsdo.h + * + * Copyright (C) 2022 Harald Welte <laforge(a)osmocom.org> + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +void usb_gpsdo_init(void); diff --git a/firmware/ice40-riscv/icE1usb/usb_str_app.txt b/firmware/ice40-riscv/icE1usb/usb_str_app.txt index 3aa6b4a..f119767 100644 --- a/firmware/ice40-riscv/icE1usb/usb_str_app.txt +++ b/firmware/ice40-riscv/icE1usb/usb_str_app.txt @@ -9,3 +9,4 @@ GPS (CDC control) GPS (CDC data) DFU runtime +GPS-DO control -- To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27017 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1-hardware Gerrit-Branch: master Gerrit-Change-Id: Icd6555a14896c38626fb147b78af44ff719f2254 Gerrit-Change-Number: 27017 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1d[master]: Allow configuration of interfaces/lines via VTY
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmo-e1d/+/27016 ) Change subject: Allow configuration of interfaces/lines via VTY ...................................................................... Allow configuration of interfaces/lines via VTY So far, osmo-e1d automatically opened all compatible icE1usb devices and all E1 lines on those interfaces. Let's allow for 'interface' and 'line' configuration in the VTY. USB devices can be identified by their serial number string. If a given device (== E1 interface) has a VTY configuration, then only those E1 lines with VTY configuration opened. For each Line (icE1usb or vpair), the mode (channelized/superchannel) can also be set via VTY. Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Closes: OS#5400 --- M src/e1d.h M src/intf_line.c M src/usb.c M src/vty.c 4 files changed, 254 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/16/27016/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27016 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Gerrit-Change-Number: 27016 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-CC: Jenkins Builder Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-e1d[master]: Allow configuration of interfaces/lines via VTY
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27016 ) Change subject: Allow configuration of interfaces/lines via VTY ...................................................................... Allow configuration of interfaces/lines via VTY So far, osmo-e1d automatically opened all compatible icE1usb devices and all E1 lines on those interfaces. Let's allow for 'interface' and 'line' configuration in the VTY. USB devices can be identified by their serial number string. If a given device (== E1 interface) has a VTY configuration, then only those E1 lines with VTY configuration opened. For each Line (icE1usb or vpair), the mode (channelized/superchannel) can also be set via VTY. Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 --- M src/e1d.h M src/intf_line.c M src/usb.c M src/vty.c 4 files changed, 254 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/16/27016/1 diff --git a/src/e1d.h b/src/e1d.h index b76df7a..d82b907 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -34,7 +34,8 @@ enum e1d_vty_node { E1D_NODE = _LAST_OSMOVTY_NODE + 1, - LINE_NODE + INTF_NODE, + LINE_NODE, }; #define line_ctr_add(line, idx, add) rate_ctr_add(rate_ctr_group_get_ctr((line)->ctrs, idx), add) @@ -147,6 +148,11 @@ struct e1_daemon *e1d; uint8_t id; + struct { + char *serial_str; + } usb; + + bool vty_created; enum e1_driver drv; void *drv_data; @@ -171,6 +177,9 @@ struct e1_intf * e1d_find_intf(struct e1_daemon *e1d, uint8_t id); +struct e1_intf * +e1d_find_intf_by_serial(struct e1_daemon *e1d, const char *serial_str); + void e1_intf_destroy(struct e1_intf *intf); diff --git a/src/intf_line.c b/src/intf_line.c index 86b0356..d1d8e95 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -95,6 +95,18 @@ return NULL; } +struct e1_intf * +e1d_find_intf_by_serial(struct e1_daemon *e1d, const char *serial_str) +{ + struct e1_intf *intf; + + llist_for_each_entry(intf, &e1d->interfaces, list) + if (intf->usb.serial_str && !strcmp(intf->usb.serial_str, serial_str)) + return intf; + + return NULL; +} + struct e1_line * e1_intf_find_line(struct e1_intf *intf, uint8_t id) { diff --git a/src/usb.c b/src/usb.c index 0100c31..1e853d3 100644 --- a/src/usb.c +++ b/src/usb.c @@ -529,9 +529,13 @@ struct e1_line *line; struct e1_usb_intf_data *intf_data; struct e1_usb_line_data *line_data; + struct libusb_device_descriptor dd; struct libusb_config_descriptor *cd; const struct libusb_interface_descriptor *id; + bool auto_create_lines; + char serial_str[64]; libusb_device_handle *devh; + int line_nr = 0; int i, j, ret; ret = libusb_open(dev, &devh); @@ -540,15 +544,53 @@ return ret; } - intf_data = talloc_zero(e1d->ctx, struct e1_usb_intf_data); - intf_data->devh = devh; + ret = libusb_get_device_descriptor(dev, &dd); + if (ret) { + LOGP(DE1D, LOGL_ERROR, "Failed to get device descriptor\n"); + libusb_close(devh); + return ret; + } - intf = e1_intf_new(e1d, -1, intf_data); - intf->drv = E1_DRIVER_USB; + ret = libusb_get_string_descriptor_ascii(devh, dd.iSerialNumber, (uint8_t *)serial_str, sizeof(serial_str)); + if (ret < 0) { + LOGP(DE1D, LOGL_ERROR, "Failed to get iSerialNumber string descriptor\n"); + libusb_close(devh); + return ret; + } + + /* try to find the matching interface config in the */ + intf = e1d_find_intf_by_serial(e1d, serial_str); + if (intf) { + LOGP(DE1D, LOGL_INFO, "configuration for icE1usb serial '%s' found\n", serial_str); + auto_create_lines = false; + if (intf->drv_data) { + LOGP(DE1D, LOGL_ERROR, "new device with serial '%s', but E1 interface %u busy\n", + serial_str, intf->id); + libusb_close(devh); + return -EBUSY; + } + intf_data = talloc_zero(e1d->ctx, struct e1_usb_intf_data); + intf_data->devh = devh; + intf->drv_data = intf_data; + } else { + LOGP(DE1D, LOGL_NOTICE, "no configuration for icE1usb serial '%s' found, " + "auto-generating it\n", serial_str); + auto_create_lines = true; + intf_data = talloc_zero(e1d->ctx, struct e1_usb_intf_data); + intf_data->devh = devh; + intf = e1_intf_new(e1d, -1, intf_data); + intf->drv = E1_DRIVER_USB; + osmo_talloc_replace_string(intf, &intf->usb.serial_str, serial_str); + } ret = libusb_get_active_config_descriptor(dev, &cd); if (ret) { LOGP(DE1D, LOGL_ERROR, "Failed to talk to usb device\n"); + intf_data->devh = NULL; + talloc_free(intf_data); + if (auto_create_lines) + e1_intf_destroy(intf); + libusb_close(devh); return ret; } @@ -561,17 +603,26 @@ if ((id->bInterfaceClass != 0xff) || (id->bInterfaceSubClass != 0xe1) || (id->bNumEndpoints < 3)) continue; + line = e1_intf_find_line(intf, line_nr); + if (line) { + OSMO_ASSERT(auto_create_lines == false); + if (line->drv_data) { + LOGPLI(line, DE1D, LOGL_ERROR, "line busy but we are trying to open it again?\n"); + goto next_interface; + } + } + /* Get interface and set it up */ ret = libusb_claim_interface(devh, id->bInterfaceNumber); if (ret) { LOGP(DE1D, LOGL_ERROR, "Failed to claim interface %d\n", id->bInterfaceNumber); - return ret; + goto next_interface; } ret = libusb_set_interface_alt_setting(devh, id->bInterfaceNumber, 1); if (ret) { LOGP(DE1D, LOGL_ERROR, "Failed to set interface %d altsetting\n", id->bInterfaceNumber); - return ret; + goto next_interface; } /* Setup driver data and find endpoints */ @@ -605,10 +656,20 @@ if (!line_data->ep_in || !line_data->ep_out || !line_data->ep_fb || !line_data->pkt_size) { LOGP(DE1D, LOGL_ERROR, "Failed to use interface %d\n", id->bInterfaceNumber); - return -EINVAL; + goto next_interface; } - line = e1_line_new(intf, -1, line_data); + if (!line) { + if (!auto_create_lines) { + LOGPIF(intf, DE1D, LOGL_ERROR, "No configuration for line %d " + "iInterface=%d, skipping\n", line_nr, id->bInterfaceNumber); + goto next_interface; + } + line = e1_line_new(intf, line_nr, line_data); + } else { + OSMO_ASSERT(auto_create_lines == false); + line->drv_data = line_data; + } line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4); line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4); @@ -620,6 +681,9 @@ if (line_data->ep_int) resubmit_irq(line); + +next_interface: + line_nr++; } return 0; diff --git a/src/vty.c b/src/vty.c index 2f2425c..7d4292c 100644 --- a/src/vty.c +++ b/src/vty.c @@ -47,15 +47,35 @@ 1, }; +static struct cmd_node intf_node = { + (enum node_type) INTF_NODE, + "%s(config-e1d-intf)# ", + 1, +}; + +static struct cmd_node line_node = { + (enum node_type) LINE_NODE, + "%s(config-e1d-intf-line)# ", + 1, +}; + #if 0 static void vty_dump_ts(struct vty *vty, const struct e1_ts *ts) { } #endif +static const char *intf_serno(const struct e1_intf *intf) +{ + if (intf->usb.serial_str) + return intf->usb.serial_str; + else + return "unnamed"; +} + static void vty_dump_intf(struct vty *vty, const struct e1_intf *intf) { - vty_out(vty, "Interface #%u, Driver: %s%s", intf->id, + vty_out(vty, "Interface #%u (%s), Driver: %s%s", intf->id, intf_serno(intf), get_value_string(e1_driver_names, intf->drv), VTY_NEWLINE); } @@ -109,8 +129,8 @@ { unsigned int tn; - vty_out(vty, "Interface #%u, Line #%u, Mode %s%s%s:%s", line->intf->id, line->id, - get_value_string(e1_line_mode_names, line->mode), + vty_out(vty, "Interface #%u (%s), Line #%u, Mode %s%s%s:%s", line->intf->id, + intf_serno(line->intf), line->id, get_value_string(e1_line_mode_names, line->mode), line->ts0.cur_errmask & E1L_TS0_RX_ALARM ? " [REMOTE-ALARM]" : "", line->ts0.cur_errmask & E1L_TS0_RX_CRC4_ERR ? " [REMOTE-CRC-ERROR]" : "", VTY_NEWLINE); @@ -177,6 +197,109 @@ return CMD_SUCCESS; } +DEFUN(cfg_e1d_if_icE1usb, cfg_e1d_if_icE1usb_cmd, "interface <0-255> icE1usb", + "Configure an icE1usb E1 interface\n" + "E1 Interface Number\n") +{ + struct e1_intf *intf; + int intf_nr = atoi(argv[0]); + + intf = e1d_find_intf(vty_e1d, intf_nr); + if (!intf) { + intf = e1_intf_new(vty_e1d, intf_nr, NULL); + } + if (!intf) { + vty_out(vty, "%% Could not create interface%s", VTY_NEWLINE); + return CMD_WARNING; + } + intf->drv = E1_DRIVER_USB; + intf->vty_created = true; + + vty->index = intf; + vty->node = INTF_NODE; + return CMD_SUCCESS; +} + +DEFUN(cfg_e1d_if_vpair, cfg_e1d_if_vpair_cmd, "interface <0-255> vpair", + "Configure a vpair member interface\n" + "E1 Interface Number\n") +{ + struct e1_intf *intf; + int intf_nr = atoi(argv[0]); + + intf = e1d_find_intf(vty_e1d, intf_nr); + if (!intf) { + vty_out(vty, "%% Could not find E1 interface %u, ddi you create it " + "using viertual-e1-pair?%s", intf_nr, VTY_NEWLINE); + return CMD_WARNING; + } + if (intf->drv != E1_DRIVER_VPAIR) { + vty_out(vty, "%% Interface %u is not a vpair interface%s", intf_nr, VTY_NEWLINE); + return CMD_WARNING; + } + intf->vty_created = true; + + vty->index = intf; + vty->node = INTF_NODE; + return CMD_SUCCESS; +} + +DEFUN(cfg_e1d_if_usb_serial, cfg_e1d_if_usb_serial_cmd, + "usb-serial SERNO", + "Configure the USB serial number of an E1 interface device\n" + "iSerial string\n") +{ + struct e1_intf *intf = vty->index; + + if (intf->drv != E1_DRIVER_USB) + return CMD_WARNING; + + osmo_talloc_replace_string(intf, &intf->usb.serial_str, argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_e1d_if_line, cfg_e1d_if_line_cmd, "line <0-255>", + "Configure an E1 line\n" + "E1 Interface Number\n") +{ + struct e1_intf *intf = vty->index; + struct e1_line *line; + int line_nr = atoi(argv[0]); + + line = e1_intf_find_line(intf, line_nr); + if (!line) + line = e1_line_new(intf, line_nr, NULL); + if (!line) { + vty_out(vty, "%% Could not create line%s", VTY_NEWLINE); + return CMD_WARNING; + } + + vty->index = line; + vty->node = LINE_NODE; + return CMD_SUCCESS; +} + +DEFUN(cfg_e1d_if_line_mode, cfg_e1d_if_line_mode_cmd, + "mode (channelized|superchannel)", + "Configure the mode of the E1 line\n" + "Channelized (64kBps timeslot) mode\n" + "Superchannel (1xHDLC over 31x64kBps) mode\n") +{ + struct e1_line *line = vty->index; + + line->mode = get_string_value(e1_line_mode_names, argv[0]); + return CMD_SUCCESS; +} + + +static int config_write_line(struct vty *vty, struct e1_line *line) +{ + vty_out(vty, " line %u%s", line->id, VTY_NEWLINE); + vty_out(vty, " mode %s%s", get_value_string(e1_line_mode_names, line->mode), VTY_NEWLINE); + + return 0; +} + static int config_write_e1d(struct vty *vty) { struct e1_intf *intf; @@ -204,6 +327,31 @@ vty_out(vty, " virtual-e1-pair %u%s", line_count, VTY_NEWLINE); } + + /* dump line config for those lines that were created by the vty */ + llist_for_each_entry(intf, &vty_e1d->interfaces, list) { + struct e1_line *line; + + if (!intf->vty_created) + continue; + + switch (intf->drv) { + case E1_DRIVER_USB: + vty_out(vty, " interface %u icE1usb%s", intf->id, VTY_NEWLINE); + if (intf->usb.serial_str && strlen(intf->usb.serial_str)) + vty_out(vty, " usb-serial %s%s", intf->usb.serial_str, VTY_NEWLINE); + break; + case E1_DRIVER_VPAIR: + vty_out(vty, " interface %u vpair%s", intf->id, VTY_NEWLINE); + break; + default: + break; + } + + llist_for_each_entry(line, &intf->lines, list) + config_write_line(vty, line); + } + return 0; } @@ -216,4 +364,13 @@ install_node(&e1d_node, config_write_e1d); install_element(CONFIG_NODE, &cfg_e1d_cmd); install_element(E1D_NODE, &cfg_vpair_cmd); + + install_node(&intf_node, NULL); + install_element(E1D_NODE, &cfg_e1d_if_icE1usb_cmd); + install_element(E1D_NODE, &cfg_e1d_if_vpair_cmd); + install_element(INTF_NODE, &cfg_e1d_if_line_cmd); + install_element(INTF_NODE, &cfg_e1d_if_usb_serial_cmd); + + install_node(&line_node, NULL); + install_element(LINE_NODE, &cfg_e1d_if_line_mode_cmd); } -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27016 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77 Gerrit-Change-Number: 27016 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1d[master]: e1_{intf,line}_new: Allow caller to specify the numeric identifier
by laforge 30 Jan '22

30 Jan '22
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27015 ) Change subject: e1_{intf,line}_new: Allow caller to specify the numeric identifier ...................................................................... e1_{intf,line}_new: Allow caller to specify the numeric identifier This will be used by the upcoming VTY interface changes. Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df --- M src/e1d.h M src/intf_line.c M src/usb.c M src/vpair.c 4 files changed, 37 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/15/27015/1 diff --git a/src/e1d.h b/src/e1d.h index a0c8ceb..b76df7a 100644 --- a/src/e1d.h +++ b/src/e1d.h @@ -166,7 +166,7 @@ e1_intf_find_line(struct e1_intf *intf, uint8_t id); struct e1_intf * -e1_intf_new(struct e1_daemon *e1d, void *drv_data); +e1_intf_new(struct e1_daemon *e1d, int intf_id, void *drv_data); struct e1_intf * e1d_find_intf(struct e1_daemon *e1d, uint8_t id); @@ -179,7 +179,7 @@ e1_intf_find_line(struct e1_intf *intf, uint8_t id); struct e1_line * -e1_line_new(struct e1_intf *intf, void *drv_data); +e1_line_new(struct e1_intf *intf, int line_id, void *drv_data); void e1_line_destroy(struct e1_line *line); diff --git a/src/intf_line.c b/src/intf_line.c index 1f833fb..86b0356 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -107,11 +107,18 @@ return NULL; } +/* intf_id can be specified as '-1' to mean "auto-allocate intf->id" */ struct e1_intf * -e1_intf_new(struct e1_daemon *e1d, void *drv_data) +e1_intf_new(struct e1_daemon *e1d, int intf_id, void *drv_data) { struct e1_intf *intf; + if (intf_id != -1) { + /* ensure non-duplicate interface number */ + if (e1d_find_intf(e1d, intf_id)) + return NULL; + } + intf = talloc_zero(e1d->ctx, struct e1_intf); OSMO_ASSERT(intf); @@ -121,10 +128,14 @@ INIT_LLIST_HEAD(&intf->list); INIT_LLIST_HEAD(&intf->lines); - if (!llist_empty(&e1d->interfaces)) { - struct e1_intf *f = llist_last_entry(&e1d->interfaces, struct e1_intf, list); - intf->id = f->id + 1; - } + if (intf_id == -1) { + if (!llist_empty(&e1d->interfaces)) { + struct e1_intf *f = llist_last_entry(&e1d->interfaces, struct e1_intf, list); + intf->id = f->id + 1; + } else + intf->id = 0; + } else + intf->id = intf_id; llist_add_tail(&intf->list, &e1d->interfaces); @@ -180,11 +191,17 @@ ts->fd = -1; } +/* line_id can be specified as '-1' to mean "auto-allocate intf->id" */ struct e1_line * -e1_line_new(struct e1_intf *intf, void *drv_data) +e1_line_new(struct e1_intf *intf, int line_id, void *drv_data) { struct e1_line *line; + if (line_id != -1) { + if (e1_intf_find_line(intf, line_id)) + return NULL; + } + line = talloc_zero(intf->e1d->ctx, struct e1_line); OSMO_ASSERT(line); @@ -198,10 +215,14 @@ INIT_LLIST_HEAD(&line->list); - if (!llist_empty(&intf->lines)) { - struct e1_line *l = llist_last_entry(&intf->lines, struct e1_line, list); - line->id = l->id + 1; - } + if (line_id == -1) { + if (!llist_empty(&intf->lines)) { + struct e1_line *l = llist_last_entry(&intf->lines, struct e1_line, list); + line->id = l->id + 1; + } else + line->id = 0; + } else + line->id = line_id; line->ctrs = rate_ctr_group_alloc(line, &line_ctrg_desc, line->id); OSMO_ASSERT(line->ctrs); diff --git a/src/usb.c b/src/usb.c index 0c0afe4..0100c31 100644 --- a/src/usb.c +++ b/src/usb.c @@ -543,7 +543,7 @@ intf_data = talloc_zero(e1d->ctx, struct e1_usb_intf_data); intf_data->devh = devh; - intf = e1_intf_new(e1d, intf_data); + intf = e1_intf_new(e1d, -1, intf_data); intf->drv = E1_DRIVER_USB; ret = libusb_get_active_config_descriptor(dev, &cd); @@ -608,7 +608,7 @@ return -EINVAL; } - line = e1_line_new(intf, line_data); + line = e1_line_new(intf, -1, line_data); line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4); line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4); diff --git a/src/vpair.c b/src/vpair.c index 8484be0..524f998 100644 --- a/src/vpair.c +++ b/src/vpair.c @@ -67,14 +67,14 @@ intf_data = talloc_zero(e1d->ctx, struct ve1_intf_data); - intf = e1_intf_new(e1d, intf_data); + intf = e1_intf_new(e1d, -1, intf_data); intf->drv = E1_DRIVER_VPAIR; for (i = 0; i < num_lines; i++) { struct ve1_line_data *line_data; line_data = talloc_zero(e1d->ctx, struct ve1_line_data); - e1_line_new(intf, line_data); + e1_line_new(intf, -1, line_data); } return intf; -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27015 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df Gerrit-Change-Number: 27015 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-e1-hardware[master]: Doc Update - Build process for DAHDI on Debian 11
by laforge 30 Jan '22

30 Jan '22
Attention is currently required from: nickvsnetworking. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27014 ) Change subject: Doc Update - Build process for DAHDI on Debian 11 ...................................................................... Patch Set 1: Code-Review+1 (2 comments) File doc/manuals/chapters/host-software.adoc: https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27014/comment/4241e351_70be… PS1, Line 53: $ sudo apt-get install -y linux-headers-`uname -r` git dfu-util make gcc autoconf libtool I think it should include 'libnewt-dev' as otherwise dahdi_tool will not be built, and I think it is the mots useful part of the dahdi-tools collection. https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27014/comment/7dd8d98f_6ccd… PS1, Line 67: At this point you can plug in the icE1usb, and scan for it with `sudo dahdi_scan` which should list the two E1 ports on the iCE1usb. it might make sense to expand a bit more, showing examle "dmesg" output, as well as stating that files in /proc/dahdi and /dev/dahdi/* should appear. -- To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/27014 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1-hardware Gerrit-Branch: master Gerrit-Change-Id: I0679bd14702b7b3d05c3346ce10358f45fef0301 Gerrit-Change-Number: 27014 Gerrit-PatchSet: 1 Gerrit-Owner: nickvsnetworking <nick(a)nickvsnetworking.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: nickvsnetworking <nick(a)nickvsnetworking.com> Gerrit-Comment-Date: Sun, 30 Jan 2022 11:19:02 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 9655
  • 9656
  • 9657
  • 9658
  • 9659
  • 9660
  • 9661
  • ...
  • 9721
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.