I know that there are some ways to configure the pattern,for example,modify the configuration file:/etc/infiniband/connect.conf.
But I was wondering if there is an interface or method to fix the mode when the driver is loading or the driver was loaded
To change IPoIB mode /etc/infiniband/openib.conf file need to be edited ( or ifcfg file when speaking about network configuration file per interfaces). To change InfiniBand or Ethernet mode need to use mlxconfig utility from MFT package, that is available from Mellanox side. You should run utility only once and the change will be persistent between the reboots.