  This paper proposes a new power control and pilot allocation scheme for
device-to-device (D2D) communication underlaying a multi-cell massive MIMO
system. In this scheme, the cellular users in each cell get orthogonal pilots
which are reused with reuse factor one across cells, while the D2D pairs share
another set of orthogonal pilots. We derive a closed-form capacity lower bound
for the cellular users with different receive processing schemes. In addition,
we derive a capacity lower bound for the D2D receivers and a closed-form
approximation of it. Then we provide a power control algorithm that maximizes
the minimum spectral efficiency (SE) of the users in the network. Finally, we
provide a numerical evaluation where we compare our proposed power control
algorithm with the maximum transmit power case and the case of conventional
multi-cell massive MIMO without D2D communication. Based on the provided
results, we conclude that our proposed scheme increases the sum spectral
efficiency of multi-cell massive MIMO networks.
