I just checked in support for a new ibv_query_device() verb, which will allow you to query (among many other things) the number of ports for a device. examples/devinfo.c in libibverbs should show how to use the new function. - R.