Connecting OpenWrt to PC Through PCIe

Hello all,

I've been playing around with using OpenWrt for an embedded router lately and was wondering if there was a way I could connect a customized OpenWrt to a PC through a PCIe slot and have the PC connect to the network hosted by OpenWrt?

In the past, I've used the usb gadget module so that I could connect my OpenWrt router to the PC as a USB device. This worked out pretty easily once I learned of kmod-usb-gadget-eth and modified the device tree to set a usb slot as a client instead of host.

I was hoping using the router as a PCIe client would be as simple as loading the right kernel module (similar to with the usb gadget), but some quick googling did not make is seem like that was the case. I was able to find an OpenWrt router that connected to a PC through a mini PCIe, but it is my understanding that it's method will not work for a normal PCIe slot.

Any insight would be greatly appreciated!

USB gadget-mode works, because USB OTG was specifically designed so that the port can be switched to be either a host or a device and yet, even then, it only works with USB OTG - ports, not regular USB - ports. There is no such mechanism defined for PCIe as far as I know, and even if there was, no consumer - grade hardware supports such -- you'd need entirely custom hardware.

Besides the above, it would most likely still just end up being USB, so it'd be a pointless and expensive endeavour, when you can just use USB OTG or just plain, old Ethernet.

well, i could certainly make a custom board. Additionally, I only need it to be a client device if the multi-use thing is part of the problem.

I thought it would work if only bc i've heard of all the old ethernet cards, which connected through PCIe

Those devices have a chipset that's designed for it, you know, and they require the OS to have drivers for them. Yes, you could design a custom OpenWrt board and chuck one of those chipsets on there and connect it to a PCIe edge connector, connect the Ethernet - pins from that chipset to the Ethernet - pins on whatever SoC you're using to run OpenWrt in, skipping the Ethernet - ports themselves -- the device would appear to the host PC as an Ethernet NIC.

1 Like

I don't think you quite understand how PCIe works either at system level or electrical level.

If you were to e.g. design a custom OpenWrt - board based on MT7621A, what peripheral would you connect to the PCIe - bus? MT7621A's own PCIe - bus is a host bus, not a device, so can't use that. I2C? Sure, except 400Kbps bandwidth isn't a lot. USB? Nope, it's a host, not a device. SPI? No, PCIe doesn't provide that. See https://en.wikipedia.org/wiki/PCI_Express#Pinout

Basically, you couldn't use any of the MT7621A's own peripherals directly, so you'd need some sort of a chipset in-between the SoC and the external PCIe - bus. Many such designs simply end up using a PCIe-to-USB bridge chipset, so that the SoC and the host PC would communicate over USB UART, but that wouldn't really be good enough for networking, so you'd need a chipset that presents itself as two Ethernet - interfaces instead (preferably with USB UART as a side-channel for management); one for the host PC and one for the SoC.

1 Like

Why? Does your PC come with external PCIe ports?

If you want to use a PCIe connection on both ends with a cable between those, then just get two PCIe ethernet cards and an ethernet cable. If you have some other use case then please provide it. The PCIe question makes no sense by itself in the context of "connecting OpenWrt to PC".

2 Likes

Create a board with a PCIe to ethernet controller, and wire it to an ethernet port on the router's chipset. You can run other ethernet ports to the outside, and have a PCIe to ethernet card that also runs OpenWrt.

The idea is to have the OpenWrt on an small computer (think about raspberry pi size) that goes inside my PC case and plugs into one of the PCIe slots on my motherboard.

Thanks for providing some feedback!

Nm, seems I misread, or you changed the post.

It'd be easier if it was there, physically, but not electronically.

So then - why not connect the Pi or whatever by PCIe Ethernet NIC and literally stuff it inside your PC's case?

Viola, connected by PCIe - custom wiring, done!

You could make it neat by using a short Etherent cable and drilling a hole into one of the case's extension port covers (if you just don't simply remove one or use another hole).

There's no converter riser/card?

Sure, but you'd need a device capable of doing so to start with. Current examples:

The primary difference here being that instead of installing the various OSes in the DPU articles, you'd use OpenWRT. We'll see more of this in the coming years as storage and memory dis-aggregation architectures pick up once PCIe gen5 is rolled out, but in the interim the DPUs are not exactly easy to purchase (my $corp get some as engineering eval units) unless in volume for OEM / ODMs.

See (WIP) Porting OpenWrt to Cavium CN6640-SNIC10E Octeon II NIC. The hardware has to have both hardware and drivers on both sides for this to work.

1 Like