diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/e1d.h | 13 | ||||
-rw-r--r-- | src/usb.c | 17 | ||||
-rw-r--r-- | src/vty.c | 43 |
3 files changed, 72 insertions, 1 deletions
@@ -78,6 +78,11 @@ enum e1_ts_mode { }; extern const struct value_string e1_ts_mode_names[]; +enum e1_framing_mode { + E1_FRAMING_MODE_CRC4 = 0, + E1_FRAMING_MODE_NO_CRC4, +}; + struct e1_ts { struct e1_line *line; uint8_t id; @@ -160,6 +165,14 @@ struct e1_line { uint32_t rx_bytes; } watchdog; + /* driver specific data */ + struct { + struct { + enum e1_framing_mode tx; + enum e1_framing_mode rx; + } framing; + } usb; + void *e1gen_priv; }; @@ -1036,14 +1036,29 @@ _e1_usb_open_device(struct e1_daemon *e1d, struct libusb_device *dev, bool is_tr goto next_interface; } - /* Create data flows and start the line */ + /* Configure, create data flows and start the line */ /* all supported devices have an IN endpoint */ + e1_usb_ctrl_set_rx_cfg(line, + (line->usb.framing.rx == E1_FRAMING_MODE_CRC4) ? + ICE1USB_RX_MODE_MULTIFRAME : + ICE1USB_RX_MODE_FRAME + ); + line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4); e1uf_start(line_data->flow_in); /* e1-tracer has no OUT or FEEDBACK endpoint */ if (!is_tracer) { + e1_usb_ctrl_set_tx_cfg(line, + (line->usb.framing.tx == E1_FRAMING_MODE_CRC4) ? + ICE1USB_TX_MODE_TS0_CRC4_E : + ICE1USB_TX_MODE_TS0, + ICE1USB_TX_TIME_SRC_LOCAL, + ICE1USB_TX_EXT_LOOPBACK_OFF, + 0x00 + ); + line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4); e1uf_start(line_data->flow_out); line_data->flow_fb = e1uf_create(line, e1_usb_xfer_fb, line_data->ep_fb, 2, 3, 1); @@ -168,6 +168,12 @@ const struct value_string e1_line_mode_names[] = { { 0, NULL } }; +const struct value_string e1_framing_mode_names[] = { + { E1_FRAMING_MODE_CRC4, "crc4" }, + { E1_FRAMING_MODE_NO_CRC4, "no-crc4" }, + { 0, NULL } +}; + static void vty_dump_line(struct vty *vty, const struct e1_line *line) { unsigned int tn; @@ -424,12 +430,47 @@ DEFUN(cfg_e1d_if_line_mode, cfg_e1d_if_line_mode_cmd, return CMD_SUCCESS; } +DEFUN(cfg_e1d_if_line_framing, cfg_e1d_if_line_framing_cmd, + "framing (no-crc4|crc4)", + NO_STR "Sets the E1 framing mode for both TX and RX\n") +{ + struct e1_line *line = vty->index; + + if (line->intf->drv != E1_DRIVER_USB) + return CMD_WARNING; + + if ((argc == 1) || (argv[0][0] == 't')) { + enum e1_framing_mode new_mode = get_string_value(e1_framing_mode_names, argv[argc-1]); + line->usb.framing.tx = new_mode; + } + + if ((argc == 1) || (argv[0][0] == 'r')) { + enum e1_framing_mode new_mode = get_string_value(e1_framing_mode_names, argv[argc-1]); + line->usb.framing.rx = new_mode; + } + + return CMD_SUCCESS; +} + +DEFUN_CMD_ELEMENT(cfg_e1d_if_line_framing, cfg_e1d_if_line_framing_txrx_cmd, + "framing (tx|rx) (no-crc4|crc4)", + NO_STR "Sets the E1 framing mode for TX or RX independently\n", 0, 0) + 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); + if (line->intf->drv == E1_DRIVER_USB) { + if (line->usb.framing.tx != line->usb.framing.rx) { + vty_out(vty, " framing tx %s%s", get_value_string(e1_framing_mode_names, line->usb.framing.tx), VTY_NEWLINE); + vty_out(vty, " framing rx %s%s", get_value_string(e1_framing_mode_names, line->usb.framing.rx), VTY_NEWLINE); + } else { + vty_out(vty, " framing %s%s", get_value_string(e1_framing_mode_names, line->usb.framing.tx), VTY_NEWLINE); + } + } + return 0; } @@ -521,4 +562,6 @@ void e1d_vty_init(struct e1_daemon *e1d) install_node(&line_node, NULL); install_element(LINE_NODE, &cfg_e1d_if_line_mode_cmd); + install_element(LINE_NODE, &cfg_e1d_if_line_framing_cmd); + install_element(LINE_NODE, &cfg_e1d_if_line_framing_txrx_cmd); } |