examples/vhost: fix mbuf allocation failure
It has always been a mystery (at least to me before) that how many
mbuf is enough while creating an mbuf pool. While current macro
NUM_MBUFS_PER_PORT gives your some insights, it's not that accurate:
it doesn't consider the case we may receive a big packet, say 64K
when TSO is enabled.
We actually have tried to fix it once before, with commit
5499c1fc9baa
("examples/vhost: fix mbuf allocation"), but it just workarounded it
by enlarging it a bit so that the case described in the commit log
by passes. So, while trying to fix it ultimately, I'm thinking how
big is big enough, and what are the factors need consider to figure
out a proper value.
Therefore, here you are. I introduced a helper function to create
the mbuf pool, and do the "how many mbufs are needed" calculation
there. Also, I put detailed comments how that comes, to serve as
the guidelines.
Fixes:
9fd72e3cbd29 ("examples/vhost: add virtio offload")
Fixes:
5499c1fc9baa ("examples/vhost: fix mbuf allocation")
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>