I used to have the exact same problem. Had a regular fuckbuddy, nice body, we got along well, the sex was great. But as good as it all was, I never got hard long enough to penetrate him. The doctors couldn't find anything wrong. I had taken antidepressants for years in my late teens and 20s which lowered my libido, so I thought they had just fucked me up permanently and I would never be a top.
Then seven years ago I moved to a new city. I went on a date with a boy who wasn't exactly my type, nor I his, so I didn't expect much to happen, then we talked and walked around the city, and I ended up falling head over heels in love. On our second date, I met his friends and we hit it off, then the two of us went for a walk by the Rhône and making out on a bench for about an hour in the cold. After he drove me home, I so much didn't want to let him go that I convinced him to come up and spend the night. Well, much to my surprise, from the make-out session by the river until we had both spent our loads that night, I remained hard almost the entire time without difficulty. I fucked him, he fucked me, and I had the time of my life.
That's when I realized the problem wasn't physical, but that I just wasn't satisfied enough with a quickie or even a regular but otherwise unavailable fuckbuddy. It took being in love with someone to unblock my cock, so to speak. Even a deep kiss from him was enough to get me to full mast.
Now, we did eventually break up. The good news is that after that, I was able to get it up with other guys. I did learn, however, that I really don't enjoy random hookups 99% of the time. If I do it too much, or with a guy who really doesn't please me, I have a hard time getting hard enough to top, or even to cum sometimes. That's why I prefer talking to someone first, getting to know them, making an emotional connection, and then if the mood strikes us, hopefully by that time I'm relaxed and in the mood and there's no problem.
So, that's my story. I'm not saying you necessarily have to fall in true love to fix your problem, but maybe it's time to start asking yourself if you're getting everything you need from this relationship. At the end of the day, though, the guys above me are right. It's almost certainly in your head. If you're nervous about something (and that includes being nervous about performing), it will be harder to get it up. Talk to your partner; it will probably help. And be sure to come back here and let us know how things go, and if you need more advice.